(interpose sep)
(interpose sep coll)
Returns a lazy seq of the elements of coll separated by sep.
Returns a stateful transducer when no collection is provided.
Source
(defn
interpose
"Returns a lazy seq of the elements of coll separated by sep.\n Returns a stateful transducer when no collection is provided."
([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))))