Skip to content

Instantly share code, notes, and snippets.

@ray1729
Created Dec 9, 2016
Embed
What would you like to do?
Insert before/after pred implemeted with split-with
(defn insert-after
[pred coll x]
(let [[before after] (split-with (complement pred) coll)]
(concat before (take 1 after) x (drop 1 after))))
(defn insert-before
[pred coll x]
(let [[before after] (split-with (complement pred) coll)]
(concat before x after)))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment