Skip to content

Instantly share code, notes, and snippets.

@Chouser
Created June 25, 2010 17:41
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 Chouser/453174 to your computer and use it in GitHub Desktop.
Save Chouser/453174 to your computer and use it in GitHub Desktop.
(defn partition-starting-with [p [x & xs :as s]]
(lazy-seq
(when-let [s (seq s)]
(let [[xa xb] (split-with (complement p) xs)]
(cons (cons x xa)
(partition-starting-with p xb))))))
(partition-starting-with #{1} [1 2 3 4 1 5 6 7 1 8 1 9 1 1 1 2 1])
@m0smith
Copy link

m0smith commented Sep 14, 2011

I like this implementation even better. Should this be contributed?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment