RANDOM() and RANDOM(FALSE) problem



Yes.
The documentation refers to computers (PDP-10, Multics) that
do not exist, and to lisp implementations (NIL) that don't
exist either.  I think that the definition for random
should be exactly the same as lisp random  (i.e. ?random)
and that random seeds etc should be handled the same way
as common lisp.

In general, if a function has been implemented in lisp
in essentially the same generality as in maxima, I think
we should just use the lisp version.
   1. The Maxima/Macsyma version was probably specified in
1968 or so, and probably made sense at the time, but
   2. The common lisp ansi definition is probably better
thought out, and should be used unless it really really
breaks something.

My opinion, anyway...

RJF
Alexander Vidybida wrote:

> Hi, friends,
> 
> It seems that RANDOM() and RANDOM(FALSE) do not work as described in
> the documentation. See example below.
> Best regards,
> --
> Alexander
> 
> -------------------------------------------------------------
> 
> Maxima version: 5.9.1
> Maxima build date: 17:35 10/8/2004
> host type: i586-pc-linux-gnu
> lisp-implementation-type: Kyoto Common Lisp
> lisp-implementation-version: GCL 2.6.5
> 
> -------------------------------------------------------------
> (%i2) describe(random)$
> 
> 
>  0: RANDOM :(maxima.info)Definitions for Operators.
> 
> Info from file /usr/local/info/maxima.info:
>  - Function: RANDOM (X)
>      returns a random integer between 0 and X-1.  If no argument is
>      given then a random integer between -2^(29) and 2^(29) -1 is
>      returned.  If X is FALSE then the random sequence is restarted from
>      the beginning.  Note that the range of the returned result when no
>      argument is given differs in NIL MACSYMA from that of PDP-10 and
>      Multics MACSYMA, which is -2^(35) to 2^(35) -1.  This range is the
>      range of the FIXNUM datatype of the underlying LISP.
> (%i3) random();
> 
> Maxima encountered a Lisp error:
> 
>  Error in MACSYMA-TOP-LEVEL [or a callee]: MACSYMA-TOP-LEVEL [or a callee] requires more than zero arguments.
> 
> Automatically continuing.
> To reenable the Lisp debugger set *debugger-hook* to nil.
> (%i4) random(FALSE);
> 
> Maxima encountered a Lisp error:
> 
>  Error in MACSYMA-TOP-LEVEL [or a callee]: NIL is not of type NUMBER.
> 
> Automatically continuing.
> To reenable the Lisp debugger set *debugger-hook* to nil.
> ----NEXT IS OK----
> (%i5) random(2^(29));
> 
> (%o5)                              322055870
> 
> 
> _______________________________________________
> Maxima mailing list
> Maxima@www.math.utexas.edu
> http://www.math.utexas.edu/mailman/listinfo/maxima