]> gitweb.factorcode.org Git - factor.git/blobdiff - basis/math/combinatorics/combinatorics-docs.factor
math.combinatorics: adding all-unique-permutations.
[factor.git] / basis / math / combinatorics / combinatorics-docs.factor
index 538654dc1fc757f114beaca00ba6a9438ea3729c..f34f537cf02f1ab67da8bc5476b5df88fb8d8bd2 100644 (file)
@@ -118,6 +118,19 @@ HELP: next-permutation
 { $notes "Performs an in-place modification of " { $snippet "seq" } "." }
 { $examples { $example "USING: math.combinatorics prettyprint ;" "\"ABC\" next-permutation ." "\"ACB\"" } } ;
 
+HELP: all-unique-permutations
+{ $values { "seq" sequence } { "seq'" sequence } }
+{ $description "Outputs a sequence containing all " { $strong "unique" } " permutations of " { $snippet "seq" } " in lexicographical order." }
+{ $examples
+    { $example "USING: math.combinatorics prettyprint ;"
+        "{ 1 1 2 } all-unique-permutations ."
+        "{ { 1 1 2 } { 1 2 1 } { 2 1 1 } }" }
+} ;
+
+HELP: each-unique-permutation
+{ $values { "seq" sequence } { "quot" { $quotation ( ... elt -- ... ) } } }
+{ $description "Applies the quotation to each " { $strong "unique" } " permutation of " { $snippet "seq" } " in order." } ;
+
 HELP: all-subsets
 { $values { "seq" sequence } { "subsets" sequence } }
 { $description