XLISP > XLISP 2.0  -  Contents  -  Reference  -  Previous | Next

random


Type:   -   function (subr)
Source:   -   xlmath.c

Syntax

(random expr)
expr - integer number or expression
returns - a random number between 0 and expr - 1.

Description

The 'random' function generates and returns a random number between 0 and 'expr' - 1. If 'expr' is negative, the number range is forced to be positive.

Examples

(random 100)      ; returns 7
(random 100)      ; returns 49
(random 100)      ; returns 73
(random -100)     ; returns 58
(random 100.01)   ; error: bad floating point operation

Common Lisp: Common Lisp allows an optional 'state' parameter, which is not supported in XLISP. Also, Common LISP allows floating point numbers, which XLISP does not support.

Note: This function is an extension of the XLISP system. It is provided in the 'msstuff.c' source code file. If your XLISP system is built for an IBM PC and compatibles, this function will work. If your system is built on UNIX or some other operating system, it will need the code in the corresponding 'stuff.c' file.

Nyquist: As far as I know the Nyquist 'random' function works on all systems. See also the Nyquist rrandom function.

See the random function in the XLISP 2.0 manual.

  Back to Top


XLISP > XLISP 2.0  -  Contents  -  Reference  -  Previous | Next