6 Accepts a positive integer or real @var{n} and returns a number of the
7 same type between zero (inclusive) and @var{n} (exclusive). The values
8 returned by @code{random} are uniformly distributed from 0 to @var{n}.
10 The optional argument @var{state} must be of the type returned by
11 @code{(seed->random-state)} or @code{(make-random-state)}. It defaults
12 to the value of the variable @code{*random-state*}. This object is used
13 to maintain the state of the pseudo-random-number generator and is
14 altered as a side effect of calls to @code{random}.
16 @defvar *random-state*
17 Holds a data structure that encodes the internal state of the
18 random-number generator that @code{random} uses by default. The nature
19 of this data structure is implementation-dependent. It may be printed
20 out and successfully read back in, but may or may not function correctly
21 as a random-number state object in another implementation.
25 @defun copy-random-state state
27 Returns a new copy of argument @var{state}.
30 @defunx copy-random-state
31 Returns a new copy of @code{*random-state*}.
34 @defun seed->random-state seed
36 Returns a new object of type suitable for use as the value of the
37 variable @code{*random-state*} or as a second argument to @code{random}.
38 The number or string @var{seed} is used to initialize the state. If
39 @code{seed->random-state} is called twice with arguments which are
40 @code{equal?}, then the returned data structures will be @code{equal?}.
41 Calling @code{seed->random-state} with unequal arguments will nearly
42 always return unequal states.
45 @defun make-random-state
48 @defunx make-random-state obj
49 Returns a new object of type suitable for use as the value of the
50 variable @code{*random-state*} or as a second argument to @code{random}.
51 If the optional argument @var{obj} is given, it should be a printable
52 Scheme object; the first 50 characters of its printed representation
53 will be used as the seed. Otherwise the value of @code{*random-state*}