]> gitweb.factorcode.org Git - factor.git/blob - unmaintained/combinators-lib/lib-docs.factor
Conflict resolution
[factor.git] / unmaintained / combinators-lib / lib-docs.factor
1 USING: help.syntax help.markup kernel prettyprint sequences
2 quotations math ;
3 IN: combinators.lib
4
5 HELP: generate
6 { $values { "generator" quotation } { "predicate" quotation } { "obj" object } }
7 { $description "Loop until the generator quotation generates an object that satisfies predicate quotation." }
8 { $unchecked-example
9     "! Generate a random 20-bit prime number congruent to 3 (mod 4)"
10     "USING: combinators.lib math math.miller-rabin prettyprint ;"
11     "[ 20 random-prime ] [ 4 mod 3 = ] generate ."
12     "526367"
13 } ;
14
15 HELP: %chance
16 { $values { "quot" quotation } { "n" integer } }
17 { $description "Calls the quotation " { $snippet "n" } " percent of the time." }
18 { $unchecked-example
19     "USING: io ;"
20     "[ \"hello, world!  maybe.\" print ] 50 %chance"
21     ""
22 } ;