summaryrefslogtreecommitdiffstats
path: root/random.txi
diff options
context:
space:
mode:
authorBryan Newbold <bnewbold@robocracy.org>2017-02-20 00:05:28 -0800
committerBryan Newbold <bnewbold@robocracy.org>2017-02-20 00:05:28 -0800
commit87b82b5822ca54228cfa6df29be3ad9d4bc47d16 (patch)
tree1eb4f87abd38bea56e08335d939e8171d5e7bfc7 /random.txi
parentbd9733926076885e3417b74de76e4c9c7bc56254 (diff)
downloadslib-87b82b5822ca54228cfa6df29be3ad9d4bc47d16.tar.gz
slib-87b82b5822ca54228cfa6df29be3ad9d4bc47d16.zip
Import Upstream version 2d2upstream/2d2
Diffstat (limited to 'random.txi')
-rw-r--r--random.txi55
1 files changed, 55 insertions, 0 deletions
diff --git a/random.txi b/random.txi
new file mode 100644
index 0000000..d9474f9
--- /dev/null
+++ b/random.txi
@@ -0,0 +1,55 @@
+
+@defun random n
+
+
+@defunx random n state
+Accepts a positive integer or real @var{n} and returns a number of the
+same type between zero (inclusive) and @var{n} (exclusive). The values
+returned by @code{random} are uniformly distributed from 0 to @var{n}.
+
+The optional argument @var{state} must be of the type returned by
+@code{(seed->random-state)} or @code{(make-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 calls to @code{random}.
+@end defun
+@defvar *random-state*
+Holds a data structure that encodes the internal state of the
+random-number generator that @code{random} uses by default. The nature
+of this data structure is implementation-dependent. It may be printed
+out and successfully read back in, but may or may not function correctly
+as a random-number state object in another implementation.
+@end defvar
+
+
+@defun copy-random-state state
+
+Returns a new copy of argument @var{state}.
+
+
+@defunx copy-random-state
+Returns a new copy of @code{*random-state*}.
+@end defun
+
+@defun seed->random-state seed
+
+Returns a new object of type suitable for use as the value of the
+variable @code{*random-state*} or as a second argument to @code{random}.
+The number or string @var{seed} is used to initialize the state. If
+@code{seed->random-state} is called twice with arguments which are
+@code{equal?}, then the returned data structures will be @code{equal?}.
+Calling @code{seed->random-state} with unequal arguments will nearly
+always return unequal states.
+@end defun
+
+@defun make-random-state
+
+
+@defunx make-random-state obj
+Returns a new object of type suitable for use as the value of the
+variable @code{*random-state*} or as a second argument to @code{random}.
+If the optional argument @var{obj} is given, it should be a printable
+Scheme object; the first 50 characters of its printed representation
+will be used as the seed. Otherwise the value of @code{*random-state*}
+is used as the seed.
+@end defun