File tree Expand file tree Collapse file tree 1 file changed +2
-21
lines changed
src/main/clojure/clojure/math Expand file tree Collapse file tree 1 file changed +2
-21
lines changed Original file line number Diff line number Diff line change @@ -71,26 +71,7 @@ Most of these algorithms are derived from algorithms found in Knuth's wonderful
71
71
"
72
72
)
73
73
74
- (defn- index-combinations
75
- [n cnt]
76
- (lazy-seq
77
- (let [c (vec (cons nil (for [j (range 1 (inc n))] (+ j cnt (- (inc n)))))),
78
- iter-comb
79
- (fn iter-comb [c j]
80
- (if (> j n) nil
81
- (let [c (assoc c j (dec (c j)))]
82
- (if (< (c j) j) [c (inc j)]
83
- (loop [c c, j j]
84
- (if (= j 1 ) [c j]
85
- (recur (assoc c (dec j) (dec (c j))) (dec j)))))))),
86
- step
87
- (fn step [c j]
88
- (cons (rseq (subvec c 1 (inc n)))
89
- (lazy-seq (let [next-step (iter-comb c j)]
90
- (when next-step (step (next-step 0 ) (next-step 1 )))))))]
91
- (step c 1 ))))
92
-
93
- (defn- index-combinations2 ; Algorithm T
74
+ (defn- index-combinations ; Algorithm T
94
75
[n cnt]
95
76
(lazy-seq
96
77
(let [c (vec (concat [nil ]
@@ -125,7 +106,7 @@ Most of these algorithms are derived from algorithms found in Knuth's wonderful
125
106
(= n 1 ) (for [item items] (list item))
126
107
(= n cnt) (list (seq items))
127
108
:else
128
- (map #(map v-items %) (index-combinations2 n cnt)))))))
109
+ (map #(map v-items %) (index-combinations n cnt)))))))
129
110
130
111
(defn- unchunk
131
112
" Given a sequence that may have chunks, return a sequence that is 1-at-a-time
You can’t perform that action at this time.
0 commit comments