Skip to content

Instantly share code, notes, and snippets.

@MarcoPolo
Created February 25, 2013 05:36
Show Gist options
  • Save MarcoPolo/5027976 to your computer and use it in GitHub Desktop.
Save MarcoPolo/5027976 to your computer and use it in GitHub Desktop.
(defn part-by-pattern [predi coll]
(reduce
(fn [result item]
(if (predi (last (last result)) item)
(conj (pop result) (conj (last result) item))
(conj result [item])))
[[(first coll)]]
(vec (rest coll))))
@mediocregopher
Copy link

You could knock a line off by making that anonymous function completely unreadable :P %1,%2

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