function | since v0.0-927 | clojure.core/interpose | Edit |
(interpose sep)
(interpose sep coll)
Returns a lazy seq of the elements of coll
separated by sep
.
Returns a lazy seq of the elements of coll separated by sep. Returns a stateful transducer when no collection is provided.
(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))))