mirror of
https://git.savannah.gnu.org/git/guile.git
synced 2025-06-11 22:31:12 +02:00
(Random): Add *random-state* variable, put note at
the top of the node about it being the default, rather than just in the description of random.
This commit is contained in:
parent
89f69c5252
commit
6deea00ef3
1 changed files with 10 additions and 6 deletions
|
@ -1229,6 +1229,11 @@ through @var{end} (exclusive) bits of @var{n}. The
|
|||
@node Random
|
||||
@subsection Random Number Generation
|
||||
|
||||
Pseudo-random numbers are generated from a random state object, which
|
||||
can be created with @code{seed->random-state}. The @var{state}
|
||||
parameter to the various functions below is optional, it defaults to
|
||||
the state object in the @code{*random-state*} variable.
|
||||
|
||||
@deffn {Scheme Procedure} copy-random-state [state]
|
||||
@deffnx {C Function} scm_copy_random_state (state)
|
||||
Return a copy of the random state @var{state}.
|
||||
|
@ -1242,12 +1247,6 @@ Accepts a positive integer or real n and returns a
|
|||
number of the same type between zero (inclusive) and
|
||||
@var{n} (exclusive). The values returned have a uniform
|
||||
distribution.
|
||||
|
||||
The optional argument @var{state} must be of the type produced
|
||||
by @code{seed->random-state}. It defaults to the value of the
|
||||
variable @code{*random-state*}. This object is used to maintain
|
||||
the state of the pseudo-random-number generator and is altered
|
||||
as a side effect of the random operation.
|
||||
@end deffn
|
||||
|
||||
@deffn {Scheme Procedure} random:exp [state]
|
||||
|
@ -1302,6 +1301,11 @@ Return a uniformly distributed inexact real random number in
|
|||
Return a new random state using @var{seed}.
|
||||
@end deffn
|
||||
|
||||
@defvar *random-state*
|
||||
The global random state used by the above functions when the
|
||||
@var{state} parameter is not given.
|
||||
@end defvar
|
||||
|
||||
|
||||
@node Characters
|
||||
@section Characters
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue