Add some code to build up all possible quotations with random-tester

release
Doug Coleman 2007-12-05 09:42:08 -06:00
parent 244558f48d
commit 6ffd6456c4
1 changed files with 11 additions and 1 deletions

View File

@ -1,5 +1,5 @@
USING: arrays assocs combinators.lib continuations kernel
math math.functions namespaces quotations random sequences
math math.functions memoize namespaces quotations random sequences
sequences.private shuffle ;
IN: random-tester.utils
@ -93,3 +93,13 @@ C: <p-list> p-list
>r make-p-list r> (each-permutation) ;
MEMO: builder-permutations ( n -- seq )
{ compose curry } swap permutations
[ >quotation ] map ; foldable
: all-quot-permutations ( seq -- newseq )
dup length 1- builder-permutations
swap [ 1quotation ] map dup length permutations
[ swap [ >r seq>stack r> call ] curry* map ] curry* map ;
! clear { map sq 10 } all-quot-permutations [ [ [ [ [ call ] keep datastack length 2 = [ . .s nl ] when ] catch ] in-thread drop ] each ] each