Created
August 26, 2011 05:46
-
-
Save ninjudd/1172787 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defn partition-with | |
"Applies f to each value in coll, splitting it each time f returns true. | |
Returns a lazy seq of partitions." | |
[f coll] | |
(lazy-seq | |
(when-let [s (seq coll)] | |
(let [[head tail] (split-with (complement f) (rest coll))] | |
(cons (cons (first coll) head) | |
(partition-with f tail)))))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment