Add some code to build up all possible quotations with random-tester
parent
244558f48d
commit
6ffd6456c4
|
@ -1,5 +1,5 @@
|
||||||
USING: arrays assocs combinators.lib continuations kernel
|
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 ;
|
sequences.private shuffle ;
|
||||||
|
|
||||||
IN: random-tester.utils
|
IN: random-tester.utils
|
||||||
|
@ -93,3 +93,13 @@ C: <p-list> p-list
|
||||||
>r make-p-list r> (each-permutation) ;
|
>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
|
||||||
|
|
Loading…
Reference in New Issue