partition-by

clojure.contrib.seq

  • (partition-by f coll)
DEPRECATED. Prefer clojure.core version.
Applies f to each value in coll, splitting it each time f returns
a new value. Returns a lazy seq of lazy seqs.

0 Examples top

Log in to add / edit an example.

See Also top

Log in to add a see also.

Plus_12x12 Minus_12x12 Source clojure/contrib/seq.clj:76 top

(defn partition-by
  "DEPRECATED. Prefer clojure.core version.
   Applies f to each value in coll, splitting it each time f returns
   a new value.  Returns a lazy seq of lazy seqs."
  {:deprecated "1.2"}
  [f coll]
  (when-let [s (seq coll)]
    (let [fst (first s)
          fv (f fst)
          run (cons fst (take-while #(= fv (f %)) (rest s)))]
      (lazy-seq
       (cons run (partition-by f (drop (count run) s)))))))
Vars in clojure.contrib.seq/partition-by: run cons count defn drop lazy-seq let partition-by when-let
Used in 0 other vars

Comments top

No comments for partition-by. Log in to add a comment.