blog
blog
Out of context: Reply #53826
- Started
- Last post
- 76,740 Responses
- drgs0
(defn concat
([] (lazy–seq nil))
([x] (lazy–seq x))
([x y]
(lazy–seq
(let [s (seq x)]
(if s
(if (chunked–seq? s)
(chunk–cons (chunk–first s) (concat (chunk–rest s) y))
(cons (first s) (concat (rest s) y)))
y))))
([x y & zs]
(let [cat (fn cat [xys zs]
(lazy–seq
(let [xys (seq xys)]
(if xys
(if (chunked–seq? xys)
(chunk–cons (chunk–first xys)
(cat (chunk–rest xys) zs))
(cons (first xys) (cat (rest xys) zs)))
(when zs
(cat (first zs) (next zs)))))))]
(cat (concat x y) zs))))
