The Random Module


random[Method]

Generates a random integer

Synopsis

random (arg, #key state) => (random-number)

Parameters

argAn instance of <integer>. Maximum number generated
state:An instance of <random-state>. The state used to generate the random number Defaults to *random-state*.

Return Values

random-numberAn instance of <integer>.

Description

Return a random integer between 0 (inclusive) and arg (exclusive). We return the same kind of integer that arg is.


random-bits[Method]

Generates a random series of bits

Synopsis

random-bits (#key state) => (bits)

Parameters

state:An instance of <random-state>. The state used to generate the random bit series. Defaults to *random-state*.

Return Values

bitsAn instance of <integer>.

Description

Returns a fixed integer that has $random-bits-count random bits. This function is the fastest way to get a random series of bits.


$random-bits-count[Constant]

Number of bits returned by random-bits.

Type

<integer>

Description

The computation of this constant takes the upper bound integer (a number larger than 1e+9) bit size and adjusts to avoid loss of randomness near the limit.


<random-state>[ sealed instantiable Class]

Used to compute a random number

Superclasses

<object>

Initialization Keywords

None.

Description

The <random-state> has slots that maintain a seed state so that a new random number can be generated.


*random-state*[Variable]

An instance that maintains the random state

Type

<random-state>

Description

Used, by default, to compute random integers and series of bits