Skip to content

Instantly share code, notes, and snippets.

@smnplk
Last active May 10, 2017 20:48
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save smnplk/4821e920ed2f14882d9a53c35e5e4910 to your computer and use it in GitHub Desktop.
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