Skip to content

Instantly share code, notes, and snippets.

@mwmitchell
Created March 16, 2012 12:44
Show Gist options
  • Save mwmitchell/2049925 to your computer and use it in GitHub Desktop.
Save mwmitchell/2049925 to your computer and use it in GitHub Desktop.
l-split-with (lazy)
(defn l-split-with [i pred]
(lazy-seq (loop [in i out []]
(if-let [f (first in)]
(if (pred f)
(list out in)
(recur (rest in) (conj out f)))))))
(l-split-with [1 2 3 4 :true true] keyword?)
; =>
'([1 2 3 4] (:true true))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment