]> gitweb.factorcode.org Git - factor.git/blobdiff - basis/combinators/random/random.factor
factor: trim using lists
[factor.git] / basis / combinators / random / random.factor
index 5a66b878cf40de5b76b23b43e78b0da26f8a8ede..ba057b055ef698eb31f0fcbfec5b7b4feb4ca101 100644 (file)
@@ -1,8 +1,7 @@
 ! Copyright (C) 2010 Jon Harper.
 ! See http://factorcode.org/license.txt for BSD license.
 USING: arrays assocs combinators combinators.short-circuit
-kernel macros math math.order quotations random sequences
-summary ;
+kernel math math.order quotations random sequences summary ;
 IN: combinators.random
 
 : ifp ( p true false -- ) [ random-unit > ] 2dip if ; inline
@@ -37,7 +36,7 @@ M: bad-probabilities summary
         cond>quot
     ] [ bad-probabilities ] if ;
 
-MACRO: (casep) ( assoc -- ) (casep>quot) ;
+MACRO: (casep) ( assoc -- quot ) (casep>quot) ;
 
 : casep>quot ( assoc -- quot )
     (casep>quot) [ random-unit ] prepend ;
@@ -47,7 +46,7 @@ MACRO: (casep) ( assoc -- ) (casep>quot) ;
     [ swap nth ] 2bi * ;
 
 : conditional-probabilities ( seq -- seq' )
-    dup length iota [ (conditional-probabilities) ] with map ;
+    dup length <iota> [ (conditional-probabilities) ] with map ;
 
 : (direct>conditional) ( assoc -- assoc' )
     [ keys conditional-probabilities ] [ values ] bi zip ;
@@ -62,11 +61,11 @@ MACRO: (casep) ( assoc -- ) (casep>quot) ;
 
 PRIVATE>
 
-MACRO: casep ( assoc -- ) casep>quot ;
+MACRO: casep ( assoc -- quot ) casep>quot ;
 
-MACRO: casep* ( assoc -- ) direct>conditional casep>quot ;
+MACRO: casep* ( assoc -- quot ) direct>conditional casep>quot ;
 
-MACRO: call-random ( seq -- ) call-random>casep casep>quot ;
+MACRO: call-random ( seq -- quot ) call-random>casep casep>quot ;
 
-MACRO: execute-random ( seq -- )
+MACRO: execute-random ( seq -- quot )
     [ 1quotation ] map call-random>casep casep>quot ;