Skip to content

Instantly share code, notes, and snippets.

Created January 11, 2010 21:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anonymous/274615 to your computer and use it in GitHub Desktop.
Save anonymous/274615 to your computer and use it in GitHub Desktop.
(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