Skip to content

Instantly share code, notes, and snippets.

@smnplk smnplk/interpose.clj
Last active May 10, 2017

Embed
What would you like to do?
Interpose and interleave examples
(defn my-interpose [element coll]
(rest (flatten (for [e coll] [element e]))))
(defn my-interleave [coll1 coll2]
(flatten (map vector coll1 coll2)))
; Both tasks are kind of similar, so we could use the interpose function to implement interleave
(defn my-interleave2 [element coll]
(my-interpose coll (repeat (count coll) element)))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.