Skip to content
This repository has been archived by the owner on May 25, 2024. It is now read-only.

Commit

Permalink
Added gen-seq
Browse files Browse the repository at this point in the history
Added gen-string
  • Loading branch information
Andrew Pennebaker committed Aug 25, 2011
1 parent 28e4a08 commit f2fab58
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 4 deletions.
2 changes: 0 additions & 2 deletions TODO
Original file line number Original file line Diff line number Diff line change
@@ -1,4 +1,2 @@
- gen-sequence
- gen-string
- example.factor - example.factor
- factcheck package - factcheck package
2 changes: 1 addition & 1 deletion example.factor
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ IN: example
! : gen-even ( -- n ) ! : gen-even ( -- n )


: main ( -- ) : main ( -- )
gen-char call . gen-string call .


! ... ! ...


Expand Down
8 changes: 7 additions & 1 deletion factcheck.factor
Original file line number Original file line Diff line number Diff line change
@@ -1,4 +1,4 @@
USING: kernel random math ; USING: kernel random math sequences strings ;
IN: factcheck IN: factcheck


! A quotation generating a random integer. ! A quotation generating a random integer.
Expand All @@ -13,6 +13,12 @@ IN: factcheck
! A quotation generating a random character. ! A quotation generating a random character.
: gen-char ( -- quot: ( -- ch ) ) [ gen-integer call 128 mod ] ; inline : 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. ! quot is a fact to check.
! seq is a sequence of quotations generating random values to pass to the fact. ! seq is a sequence of quotations generating random values to pass to the fact.
! !
Expand Down

0 comments on commit f2fab58

Please sign in to comment.