/gist:73c9627bb97c36bbe6e0 Secret
Created
January 30, 2011 15:43
Star
You must be signed in to star a gist
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 interleave* | |
([c1] c1) | |
([c1 c2] | |
(lazy-seq | |
(let [s1 (seq c1) s2 (seq c2)] | |
(if (and s1 s2) | |
(cons (first s1) (cons (first s2) | |
(interleave* (rest s1) (rest s2)))) | |
(or s1 s2))))) | |
([c1 c2 & colls] | |
(lazy-seq | |
(let [ss (filter identity (map seq (conj colls c2 c1)))] | |
(when (seq ss) | |
(concat (map first ss) (apply interleave* (map rest ss)))))))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment