((section 2 "Outdated egg!" (p "This is an egg for CHICKEN 4, the unsupported old release.  You're almost certainly looking for " (int-link "/eggref/5/combinatorics" "the CHICKEN 5 version of this egg") ", if it exists.") (p "If it does not exist, there may be equivalent functionality provided by another egg; have a look at the " (link "https://wiki.call-cc.org/chicken-projects/egg-index-5.html" "egg index") ". Otherwise, please consider porting this egg to the current version of CHICKEN.")) (section 2 "combinatorics" (p "Combinatorics") (toc) (section 3 "Abstract" (p (tt "Combinatorics") " provides some mechanisms for iterating over, reducing and mapping permutations (ordered subsets) and combinations (unordered subsets) of lists.") (p (tt "Combinatorics") " supports partial, i.e. " (i "k") "-permutations and partial, i.e. " (i "k") "-combinations.")) (section 3 "Documentation" (section 4 (tt "ordered-subset-for-each") (def (sig (procedure "(ordered-subset-for-each f list) → unspecified" (id ordered-subset-for-each)) (procedure "(ordered-subset-for-each f list k) → unspecified" (id ordered-subset-for-each))) (p "Iterate over every " (i "k") "-permutation (partial ordered subset) of " (tt "list") ", calling " (tt "f") " for its side effect.") (dl (dt (tt "f")) (dd "The function to call") (dt (tt "list")) (dd "The list to permute") (dt (tt "k")) (dd (i "k") " distinct elements (default: " (i "n") ")")) (highlight scheme "(define ordered-subset-for-each\n  (case-lambda\n    ((f list) (ordered-subset-for-each f list (length list)))\n    ((f list k)\n     (let iter ((list list) (k k) (subset '()))\n       (if (zero? k)\n         (f subset)\n         (for-each\n           (lambda (element)\n             (iter (delete element list) (sub1 k) (cons element subset)))\n           list))))))"))) (section 4 (tt "ordered-subset-fold") (def (sig (procedure "(ordered-subset-fold cons nil list) → object" (id ordered-subset-fold)) (procedure "(ordered-subset-fold cons nil list k) → object" (id ordered-subset-fold))) (p "Recombine every " (i "k") "-permutation (partial ordered subset) of " (tt "list") ", starting with a base-case " (tt "nil") ", and calling " (tt "cons") " with 1. a permutation and 2. the accumulated value.") (dl (dt (tt "cons")) (dd "The combining function") (dt (tt "nil")) (dd "The base case") (dt (tt "list")) (dd "The list to recombine") (dt (tt "k")) (dd (i "k") " distinct elements (default: " (i "n") ")")) (highlight scheme "(define ordered-subset-fold\n  (case-lambda\n    ((cons nil list) (ordered-subset-fold cons nil list (length list)))\n    ((cons nil list k)\n     (let ((nil (make-parameter nil)))\n       (ordered-subset-for-each\n         (lambda (subset) (nil (cons subset (nil))))\n         list\n         k)\n       (nil)))))"))) (section 4 (tt "ordered-subset-map") (def (sig (procedure "(ordered-subset-map f list) → list" (id ordered-subset-map)) (procedure "(ordered-subset-map f list k) → list" (id ordered-subset-map))) (p "Map every " (i "k") "-permutation (partial ordered subset) of " (tt "list") " using " (tt "f") ".") (dl (dt (tt "f")) (dd "The mapping function") (dt (tt "list")) (dd "The list to map") (dt (tt "k")) (dd (i "k") " distinct elements (default: " (i "n") ")")) (highlight scheme "(define ordered-subset-map\n  (case-lambda\n    ((f list) (ordered-subset-map f list (length list)))\n    ((f list k)\n     (ordered-subset-fold (lambda (v a) (cons (f v) a)) '() list k))))"))) (section 4 (tt "unordered-subset-for-each") (def (sig (procedure "(unordered-subset-for-each f list) → unspecified" (id unordered-subset-for-each)) (procedure "(unordered-subset-for-each f list k) → unspecified" (id unordered-subset-for-each))) (p "Iterate over every " (i "k") "-combination (partial unordered subset) of " (tt "list") ", calling " (tt "f") " for its side effect.") (dl (dt (tt "f")) (dd "The function to call") (dt (tt "list")) (dd "The list to permute") (dt (tt "k")) (dd (i "k") " distinct elements (default: " (i "n") ")")) (highlight scheme "(define unordered-subset-for-each\n  (case-lambda\n    ((f list) (unordered-subset-for-each f list (length list)))\n    ((f list k)\n     (let ((subset (make-vector k)) (n (length list)))\n       (let iter ((start 0) (p 0))\n         (if (= p k)\n           (f (project subset list))\n           (do ((i start (+ i 1)))\n               ((= i n))\n             (vector-set! subset p i)\n             (iter (add1 i) (add1 p)))))))))"))) (section 4 (tt "unordered-subset-fold") (def (sig (procedure "(unordered-subset-fold cons nil list) → object" (id unordered-subset-fold)) (procedure "(unordered-subset-fold cons nil list k) → object" (id unordered-subset-fold))) (p "Recombine every " (i "k") "-combination (partial unordered subset) of " (tt "list") ", starting with a base-case " (tt "nil") ", and calling " (tt "cons") " with 1. a combination and 2. the accumulated value.") (dl (dt (tt "cons")) (dd "The combining function") (dt (tt "nil")) (dd "The base case") (dt (tt "list")) (dd "The list to recombine") (dt (tt "k")) (dd (i "k") " distinct elements (default: " (i "n") ")")) (highlight scheme "(define unordered-subset-fold\n  (case-lambda\n    ((cons nil list) (unordered-subset-fold cons nil list (length list)))\n    ((cons nil list k)\n     (let ((nil (make-parameter nil)))\n       (unordered-subset-for-each\n         (lambda (subset) (nil (cons subset (nil))))\n         list\n         k)\n       (nil)))))"))) (section 4 (tt "unordered-subset-map") (def (sig (procedure "(unordered-subset-map f list) → list" (id unordered-subset-map)) (procedure "(unordered-subset-map f list k) → list" (id unordered-subset-map))) (p "Map every " (i "k") "-combination (partial unordered subset) of " (tt "list") " using " (tt "f") ".") (dl (dt (tt "f")) (dd "The mapping function") (dt (tt "list")) (dd "The list to map") (dt (tt "k")) (dd (i "k") " distinct elements (default: " (i "n") ")")) (highlight scheme "(define unordered-subset-map\n  (case-lambda\n    ((f list) (unordered-subset-map f list (length list)))\n    ((f list k)\n     (unordered-subset-fold (lambda (v a) (cons (f v) a)) '() list k))))"))) (section 4 (tt "permutation-for-each") (def (sig (constant "permutation-for-each → ordered-subset-for-each" (id permutation-for-each))) (p "Synonym for " (int-link "#ordered-subset-for-each" "ordered-subset-for-each")) (highlight scheme "(define permutation-for-each ordered-subset-for-each)"))) (section 4 (tt "permutation-fold") (def (sig (constant "permutation-fold → ordered-subset-fold" (id permutation-fold))) (p "Synonym for " (int-link "#ordered-subset-fold" "ordered-subset-fold")) (highlight scheme "(define permutation-fold ordered-subset-fold)"))) (section 4 (tt "permutation-map") (def (sig (constant "permutation-map → ordered-subset-map" (id permutation-map))) (p "Synonym for " (int-link "#ordered-subset-map" "ordered-subset-map")) (highlight scheme "(define permutation-map ordered-subset-map)"))) (section 4 (tt "combination-for-each") (def (sig (constant "combination-for-each → unordered-subset-for-each" (id combination-for-each))) (p "Synonym for " (int-link "#unordered-subset-for-each" "unordered-subset-for-each")) (highlight scheme "(define combination-for-each unordered-subset-for-each)"))) (section 4 (tt "combination-fold") (def (sig (constant "combination-fold → unordered-subset-fold" (id combination-fold))) (p "Synonym for " (int-link "#unordered-subset-fold" "unordered-subset-fold")) (highlight scheme "(define combination-fold unordered-subset-fold)"))) (section 4 (tt "combination-map") (def (sig (constant "combination-map → unordered-subset-map" (id combination-map))) (p "Synonym for " (int-link "#unordered-subset-map" "unordered-subset-map")) (highlight scheme "(define combination-map unordered-subset-map)")))) (section 3 "About this egg" (section 4 "Author" (p (int-link "/users/klutometis" "Peter Danenberg"))) (section 4 "Repository" (p (link "https://github.com/klutometis/combinatorics"))) (section 4 "License" (p "BSD")) (section 4 "Dependencies" (ul (li (int-link "hahn")) (li (int-link "setup-helper")) (li (int-link "vector-lib")))) (section 4 "Versions" (dl (dt (link "https://github.com/klutometis/combinatorics/releases/tag/0.1" "0.1")) (dd "Start with ordered-subset operations.") (dt (link "https://github.com/klutometis/combinatorics/releases/tag/0.2" "0.2")) (dd "Add unordered subset operations.") (dt (link "https://github.com/klutometis/combinatorics/releases/tag/0.3" "0.3")) (dd "Add documentation.") (dt (link "https://github.com/klutometis/combinatorics/releases/tag/0.3.1" "0.3.1")) (dd "Add some tests.") (dt (link "https://github.com/klutometis/combinatorics/releases/tag/0.3.2" "0.3.2")) (dd "Tests depend on `test'.") (dt (link "https://github.com/klutometis/combinatorics/releases/tag/0.3.3" "0.3.3")) (dd "Actually map the values.") (dt (link "https://github.com/klutometis/combinatorics/releases/tag/0.3.4" "0.3.4")) (dd "Add the combination- and permutation-synonyms.") (dt (link "https://github.com/klutometis/combinatorics/releases/tag/0.3.5" "0.3.5")) (dd "Remove the dependency on setup-helper-cock.") (dt (link "https://github.com/klutometis/combinatorics/releases/tag/0.3.6" "0.3.6")) (dd "Bump the version.") (dt (link "https://github.com/klutometis/combinatorics/releases/tag/0.3.7" "0.3.7")) (dd "Use `use' instead of `include'.") (dt (link "https://github.com/klutometis/combinatorics/releases/tag/0.3.8" "0.3.8")) (dd "Use hahn."))) (section 4 "Colophon" (p "Documented by " (int-link "/egg/hahn" "hahn") ".")))))