aboutsummaryrefslogtreecommitdiff
path: root/src/clojure
diff options
context:
space:
mode:
authorChristophe Grand <christophe@cgrand.net>2009-01-29 14:56:41 +0000
committerChristophe Grand <christophe@cgrand.net>2009-01-29 14:56:41 +0000
commit6e29c274e6b018b409086bdde80f442f65312830 (patch)
treed9f7620ba67aa6118cd2f8df2a2ffe63f286666d /src/clojure
parent5dfd27a126bba464e12183b8a96102742e93a9e7 (diff)
Fixed partition-by to work on vectors, arrays or ranges (generally when (identical? (rest s) (rest s)) returns false).
Diffstat (limited to 'src/clojure')
-rw-r--r--src/clojure/contrib/seq_utils.clj7
1 files changed, 2 insertions, 5 deletions
diff --git a/src/clojure/contrib/seq_utils.clj b/src/clojure/contrib/seq_utils.clj
index 04479e4e..c559cb1b 100644
--- a/src/clojure/contrib/seq_utils.clj
+++ b/src/clojure/contrib/seq_utils.clj
@@ -76,11 +76,8 @@
[f coll]
(when-let [s (seq coll)]
(let [fv (f (first s))
- ends (drop-while #(= fv (f %)) (rest s))
- tw (fn this [s]
- (when-not (identical? s ends)
- (lazy-cons (first s) (this (rest s)))))]
- (lazy-cons (tw s) (partition-by f ends)))))
+ run (take-while #(= fv (f %)) s)]
+ (lazy-cons run (partition-by f (drop (count run) s))))))
(defn frequencies
"Returns a map from distinct items in coll to the number of times