Skip to content

Instantly share code, notes, and snippets.

@danlarkin
Created August 28, 2010 22:42
Show Gist options
  • Save danlarkin/555658 to your computer and use it in GitHub Desktop.
Save danlarkin/555658 to your computer and use it in GitHub Desktop.
(defn interleave-all [c1 c2]
(lazy-seq
(let [s1 (seq c1) s2 (seq c2)]
(when (or s1 s2)
(cons (first s1) (cons (first s2)
(interleave-all (rest s1) (rest s2))))))))
=> (interleave [1 2 3] '[a b])
(1 a 2 b)
=> (interleave-all [1 2 3] '[a b])
(1 a 2 b 3 nil)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment