]> gitweb.factorcode.org Git - factor.git/commitdiff
math.combinatorics: cleanup stack effects to be more descriptive.
authorJohn Benediktsson <mrjbq7@gmail.com>
Thu, 18 Apr 2013 14:15:47 +0000 (07:15 -0700)
committerJohn Benediktsson <mrjbq7@gmail.com>
Thu, 18 Apr 2013 14:15:47 +0000 (07:15 -0700)
basis/math/combinatorics/combinatorics-docs.factor
basis/math/combinatorics/combinatorics.factor

index b3fc7751e1a339097d101d76e58992d8f8b291ba..105fbe5103defdd03de2e1997a299ad62d52197c 100644 (file)
@@ -49,7 +49,7 @@ HELP: all-permutations
 } ;
 
 HELP: each-permutation
-{ $values { "seq" sequence } { "quot" { $quotation "( seq -- )" } } }
+{ $values { "seq" sequence } { "quot" { $quotation "( ... elt -- ... )" } } }
 { $description "Applies the quotation to each permutation of " { $snippet "seq" } " in order." } ;
 
 HELP: inverse-permutation
@@ -94,7 +94,7 @@ HELP: all-combinations
 }""" } } ;
 
 HELP: each-combination
-{ $values { "seq" sequence } { "k" "a non-negative integer" } { "quot" { $quotation "( seq -- )" } } }
+{ $values { "seq" sequence } { "k" "a non-negative integer" } { "quot" { $quotation "( ... elt -- ... )" } } }
 { $description "Applies the quotation to each combination of " { $snippet "seq" } " choosing " { $snippet "k" } " elements, in order." } ;
 
 
index 7d7327de1a973508fa0d33b6b183071880ff9235..d5e782de6a78f9db145d13d1c374d18e09e99ac9 100644 (file)
@@ -75,23 +75,23 @@ DEFER: next-permutation
 
 PRIVATE>
 
-: each-permutation ( seq quot -- )
+: each-permutation ( ... seq quot: ( ... elt -- ... ) -- ... )
     permutations-quot each ; inline
 
-: map-permutations ( seq quot -- seq' )
+: map-permutations ( ... seq quot: ( ... elt -- ... newelt ) -- ... newseq )
     permutations-quot map ; inline
 
-: filter-permutations ( seq quot -- seq' )
+: filter-permutations ( ... seq quot: ( ... elt -- ... ? ) -- ... newseq )
     selector [ each-permutation ] dip ; inline
 
 : all-permutations ( seq -- seq' )
     [ ] map-permutations ;
 
-: find-permutation ( seq quot -- elt )
+: find-permutation ( ... seq quot: ( ... elt -- ... ? ) -- ... elt/f )
     [ permutations-quot find drop ]
     [ drop over [ permutation ] [ 2drop f ] if ] 2bi ; inline
 
-: reduce-permutations ( seq identity quot -- result )
+: reduce-permutations ( ... seq identity quot: ( ... prev elt -- ... next ) -- ... result )
     swapd each-permutation ; inline
 
 : inverse-permutation ( seq -- permutation )
@@ -185,26 +185,26 @@ INSTANCE: combinations immutable-sequence
 
 PRIVATE>
 
-: each-combination ( seq k quot -- )
+: each-combination ( ... seq k quot: ( ... elt -- ... ) -- ... )
     combinations-quot each ; inline
 
-: map-combinations ( seq k quot -- seq' )
+: map-combinations ( ... seq k quot: ( ... elt -- ... newelt ) -- ... newseq )
     combinations-quot map ; inline
 
-: filter-combinations ( seq k quot -- seq' )
+: filter-combinations ( ... seq k quot: ( ... elt -- ... ? ) -- ... newseq )
     selector [ each-combination ] dip ; inline
 
-:: map>assoc-combinations ( seq k quot exemplar -- )
+:: map>assoc-combinations ( ... seq k quot: ( ... elt -- ... key value ) exemplar -- ... assoc )
     [ combinations-quot ] dip map>assoc ; inline
 
 : all-combinations ( seq k -- seq' )
     [ ] map-combinations ;
 
-: find-combination ( seq k quot -- elt/f )
+: find-combination ( ... seq k quot: ( ... elt -- ... ? ) -- ... elt/f )
     [ combinations-quot find drop ]
     [ drop pick [ combination ] [ 3drop f ] if ] 3bi ; inline
 
-: reduce-combinations ( seq k identity quot -- result )
+: reduce-combinations ( ... seq k identity quot: ( ... prev elt -- next ) -- ... result )
     [ -rot ] dip each-combination ; inline
 
 : all-subsets ( seq -- subsets )