interleave

functionsince v0.0-927 clojure.core/interleaveEdit
(interleave)
(interleave c1)
(interleave c1 c2)
(interleave c1 c2 & colls)

Details:

Returns a lazy seq of the first item in each collection, then the second items, then the third, etc.


See Also:


Source docstring:
Returns a lazy seq of the first item in each coll, then the second etc.
Source code @ clojurescript:src/main/cljs/cljs/core.cljs
(defn interleave
  ([] ())
  ([c1] (lazy-seq c1))
  ([c1 c2]
     (lazy-seq
      (let [s1 (seq c1) s2 (seq c2)]
        (when (and s1 s2)
          (cons (first s1) (cons (first s2)
                                 (interleave (rest s1) (rest s2))))))))
  ([c1 c2 & colls]
     (lazy-seq
      (let [ss (map seq (conj colls c2 c1))]
        (when (every? identity ss)
          (concat (map first ss) (apply interleave (map rest ss))))))))