interpose

functionsince v0.0-927 clojure.core/interposeEdit
(interpose sep)
(interpose sep coll)

Details:

Returns a lazy seq of the elements of coll separated by sep.


See Also:


Source docstring:
Returns a lazy seq of the elements of coll separated by sep.
Returns a stateful transducer when no collection is provided.
Source code @ clojurescript:src/main/cljs/cljs/core.cljs
(defn interpose
  ([sep]
    (fn [rf]
      (let [started (volatile! false)]
        (fn
          ([] (rf))
          ([result] (rf result))
          ([result input]
            (if @started
              (let [sepr (rf result sep)]
                (if (reduced? sepr)
                  sepr
                  (rf sepr input)))
              (do
                (vreset! started true)
                (rf result input))))))))
  ([sep coll] (drop 1 (interleave (repeat sep) coll))))