Created
January 11, 2010 21:20
-
-
Save anonymous/274615 to your computer and use it in GitHub Desktop.
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 concat-seq | |
"Concatenate sequence of sequences into one sequence of elements | |
from all sequences. Concatenation is made in a lazy fashion." | |
([e] | |
(lazy-seq | |
(when-let [s (seq e)] | |
(let [f (first s)] | |
(cons (first f) (concat-seq (rest f) (rest s))))))) | |
([r e] | |
(lazy-seq | |
(if-let [s (seq r)] | |
(cons (first s) (concat-seq (rest s) e)) | |
(concat-seq e))))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment