{ "seed" "a seed specific to the random number generator" }
}
{ $description "Seed the random number generator. Repeatedly seeding the random number generator should provide the same sequence of random numbers." }
{ $notes "Not supported on all random number generators." } ;
HELP: random-32*
-{ $values { "obj" "a random number generator" } { "n" "an integer between 0 and 2^32-1" } }
+{ $values { "rnd" "a random number generator" } { "n" "an integer between 0 and 2^32-1" } }
{ $description "Generates a random 32-bit unsigned integer." } ;
+HELP: random-32
+{ $values { "n" "a 32-bit random integer" } }
+{ $description "Outputs 32 random bits. This word is more efficient than calling " { $link random } " because no scaling is done on the output." } ;
+
+{ random-32* random-32 } related-words
+
HELP: random-bytes*
-{ $values { "n" integer } { "obj" "a random number generator" } { "byte-array" "a sequence of random bytes" } }
+{ $values { "n" integer } { "rnd" "a random number generator" } { "byte-array" "a sequence of random bytes" } }
{ $description "Generates a byte-array of " { $snippet "n" } " random bytes." } ;
+HELP: random-bytes
+{ $values { "n" integer } { "byte-array" "a sequence of random bytes" } }
+{ $description "Generates a byte-array of " { $snippet "n" } " random bytes." }
+{ $examples
+ { $unchecked-example "USING: prettyprint random ;"
+ "5 random-bytes ."
+ "B{ 135 50 185 119 240 }"
+ }
+} ;
+
+{ random-bytes* random-bytes } related-words
+
+HELP: random*
+{ $values { "obj" object } { "rnd" "a random number generator" } { "elt" "a random element" } }
+{ $description "Outputs a random element of the input object, or outputs " { $link f } " if the object contains no elements." } ;
+
HELP: random
{ $values { "obj" object } { "elt" "a random element" } }
{ $description "Outputs a random element of the input object, or outputs " { $link f } " if the object contains no elements." }
{ $description "Returns an integer exactly " { $snippet "numbits" } " bits in length, with the topmost bit set to one." } ;
HELP: with-random
-{ $values { "obj" "a random number generator" } { "quot" quotation } }
+{ $values { "rnd" "a random number generator" } { "quot" quotation } }
{ $description "Calls the quotation with the random number generator in a dynamic variable. All random numbers will be generated using this random number generator." } ;
HELP: with-secure-random
@@ -140,8+150,8 @@ ARTICLE: "random" "Generating random integers"
$nl
"The “Mersenne Twister” pseudorandom number generator algorithm is the default generator stored in " { $link random-generator } "."
$nl
-"Generate a random object:"
-{ $subsections random }
+"Generate random object(s):"
+{ $subsections random randoms }
"Efficient 32-bit random numbers:"
{ $subsections random-32 }
"Combinators to change the random number generator:"
-{ $description "Creates a " { $snippet "m x n" } " " { $link matrix } " full of random, possibly signed " { $link integer } "s whose absolute values are less than or equal to " { $snippet "max" } ", as given by " { $link random-integers } "." }
+{ $description "Creates a " { $snippet "m x n" } " " { $link matrix } " full of random, possibly signed " { $link integer } "s whose absolute values are less than or equal to " { $snippet "max" } ", as given by " { $link randoms } "." }
{ $notelist
{ "The signedness of the numbers in the resulting matrix will be randomized. Use " { $link mabs } " with this word to generate a matrix of random positive integers." }