From: Robert White
Subject: Random number generator
Date: 
Message-ID: <Wk0H7.1005$oM5.88237@typhoon.mw.mediaone.net>
hello everyone

is there a lisp command to generate a random number


Bob White

From: JP Massar
Subject: Re: Random number generator
Date: 
Message-ID: <3becb1ce.385571873@news>
On Sat, 10 Nov 2001 02:32:22 GMT, "Robert White"
<·······@mediaone.net> wrote:

>hello everyone
>
>is there a lisp command to generate a random number
>
 
RANDOM

e.g.

(random 100) 

returns an integer between 0 and 99 inclusive.
From: Kaz Kylheku
Subject: Re: Random number generator
Date: 
Message-ID: <G33H7.31557$Ud.1288175@news1.rdc1.bc.home.com>
In article <····················@typhoon.mw.mediaone.net>, Robert White wrote:
>hello everyone
>
>is there a lisp command to generate a random number

Not exactly. 

Firstly, a pedantic nitpick: Lisp doesn't have ``commands''.
Objects that are evaluated are called ``forms'': invocations of
macros, functions or operators are forms.

Second, Common Lisp provides only a function for generating sequences
of *pseudo*-random numbers, not random numbers (although the function
is just called random).

If you are looking for truly random numbers, which are needed
for applications like cryptography, you need to obtain them from some
real-world inputs that behave chaotically.

If pseudo-random numbers *are* what you want, they are reasonably
well-supported in Lisp. There is a standard abstraction of random state:
a random state is an object which maintains information for generating
a pseudo-random sequence. You can construct a new random state object
like this:

	(setf my-rand-state (make-random-state t))

Then you can use the object as an argument to the random function.
For instance to generate a pseudo-random integer in the range 0 to 9:

	(setf random-number (random 10 my-rand-state))

If you don't specify a random state parameter, then random will implicitly
use the standard global object *random-state*, which represents the
current random state.

To learn more details, look up these symbols in the Common
Lisp HyperSpec:

http://www.xanalys.com/software_tools/reference/HyperSpec/FrontMatter/