2007-12-11 22:36:40 -05:00
|
|
|
USING: help.syntax help.markup kernel prettyprint sequences
|
|
|
|
quotations math ;
|
2007-09-20 18:09:08 -04:00
|
|
|
IN: combinators.lib
|
|
|
|
|
|
|
|
HELP: generate
|
2007-12-11 22:36:40 -05:00
|
|
|
{ $values { "generator" quotation } { "predicate" quotation } { "obj" object } }
|
2007-09-20 18:09:08 -04:00
|
|
|
{ $description "Loop until the generator quotation generates an object that satisfies predicate quotation." }
|
|
|
|
{ $unchecked-example
|
|
|
|
"! Generate a random 20-bit prime number congruent to 3 (mod 4)"
|
2008-03-11 20:51:58 -04:00
|
|
|
"USING: combinators.lib math math.miller-rabin prettyprint ;"
|
2007-09-20 18:09:08 -04:00
|
|
|
"[ 20 random-prime ] [ 4 mod 3 = ] generate ."
|
|
|
|
"526367"
|
|
|
|
} ;
|