function | since v0.0-2301 | clojure.core/dedupe | Edit |
(dedupe)
(dedupe coll)
Returns a lazy sequence removing consecutive duplicates in coll. Returns a transducer when no collection is provided.
(defn dedupe
([]
(fn [rf]
(let [pa (volatile! ::none)]
(fn
([] (rf))
([result] (rf result))
([result input]
(let [prior @pa]
(vreset! pa input)
(if (= prior input)
result
(rf result input))))))))
([coll] (sequence (dedupe) coll)))