Document a couple of words in random

Add a word to get a random 256-bit integer
release
Doug Coleman 2007-11-05 02:25:16 -06:00
parent 18a554ad4d
commit 5719eeda88
2 changed files with 10 additions and 0 deletions

View File

@ -21,3 +21,11 @@ HELP: random
{ $values { "seq" "a sequence" } { "elt" "a random element" } }
{ $description "Outputs a random element of the sequence. If the sequence is empty, always outputs " { $link f } "." }
{ $notes "Since integers are sequences, passing an integer " { $snippet "n" } " yields a random integer in the interval " { $snippet "[0,n)" } "." } ;
HELP: big-random
{ $values { "n" "an integer" } { "r" "a random integer" } }
{ $description "Outputs an integer with n bytes worth of bits." } ;
HELP: random-256
{ $values { "r" "a random integer" } }
{ $description "Outputs an random integer 256 bits in length." } ;

View File

@ -93,6 +93,8 @@ PRIVATE>
: big-random ( n -- r )
[ drop (random) ] map >c-uint-array byte-array>bignum ;
: random-256 ( -- r ) 8 big-random ; inline
: random ( seq -- elt )
dup empty? [
drop f