clojure.core/distinct¶
Returns a lazy sequence of the elements of coll with duplicates removed. Returns a stateful transducer when no collection is provided.
Examples¶
Note by morphling¶
If you do not need the lazyness of distinct, set can be faster. Like: (count (set some-coll)).
Note by vshatsky¶
Use this function if you want to remove only consequtive duplicates
(defn distinct-consequtive [sequence] (map first (partition-by identity sequence)))
(distinct-consequtive [1 1 2 3 3 2 2 3])
;=> (1 2 3 2 3)
Note by bfontaine¶
Use dedupe if you want to remove consecutive duplicates, available since Clojure 1.7.
See also¶
Content from the matching ClojureDocs page, with authors credited on each contribution.