Last active
May 10, 2017 20:48
Star
You must be signed in to star a gist
Interpose and interleave examples
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(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