Skip to content

Instantly share code, notes, and snippets.

@arnaudbos
Last active August 29, 2015 13:56
Show Gist options
  • Save arnaudbos/9072443 to your computer and use it in GitHub Desktop.
Save arnaudbos/9072443 to your computer and use it in GitHub Desktop.
clojure partition-with
(defn partition-with
[f coll]
{:pre [(fn? f) (coll? coll)]}
(let [coll (partition-by f coll)
coll (partition 2 coll)
coll (map #(concat (first %) (second %)) coll)
]
coll))
(defn partition-on
[f coll]
{:pre [(fn? f) (coll? coll)]}
(let [coll (partition-by f coll)
coll (filter #(not (f (first %))) coll)]
coll))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment