Permalink
Browse files

Added gen-seq

Added gen-string
  • Loading branch information...
1 parent 28e4a08 commit f2fab5836d7348ccaf321765028336f5d28be26b @mcandre committed Aug 25, 2011
Showing with 8 additions and 4 deletions.
  1. +0 −2 TODO
  2. +1 −1 example.factor
  3. +7 −1 factcheck.factor
View
2 TODO
@@ -1,4 +1,2 @@
- - gen-sequence
- - gen-string
- example.factor
- factcheck package
View
@@ -7,7 +7,7 @@ IN: example
! : gen-even ( -- n )
: main ( -- )
- gen-char call .
+ gen-string call .
! ...
View
@@ -1,4 +1,4 @@
-USING: kernel random math ;
+USING: kernel random math sequences strings ;
IN: factcheck
! A quotation generating a random integer.
@@ -13,6 +13,12 @@ IN: factcheck
! A quotation generating a random character.
: gen-char ( -- quot: ( -- ch ) ) [ gen-integer call 128 mod ] ; inline
+! A quotation generating a random sequence.
+: gen-seq ( quot: ( -- obj ) -- quot: ( -- seq ) ) [ gen-integer call 100 mod swap replicate ] ; inline
+
+! A quotation generating a random string.
+: gen-string ( -- str ) [ gen-char gen-seq call >string ] ; inline
+
! quot is a fact to check.
! seq is a sequence of quotations generating random values to pass to the fact.
!

0 comments on commit f2fab58

Please sign in to comment.