Skip to content

Instantly share code, notes, and snippets.

@MichaelBlume
Created May 17, 2013 00:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save MichaelBlume/5596160 to your computer and use it in GitHub Desktop.
Save MichaelBlume/5596160 to your computer and use it in GitHub Desktop.
(defn my-split-with [pred coll]
(let [p (promise)
passes ((fn step [c]
(lazy-seq
(if-let [[x & xs] (seq c)]
(if (pred x)
(cons x (step xs))
(do (deliver p c) nil))
(do (deliver p nil) nil))))
coll)]
[passes
(lazy-seq (do (dorun passes) @p))]))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment