Merge pull request #494 from theanalyst/fix/distinct
faster distinct: maintain seen items in a set
This commit is contained in:
commit
e6a6249eab
@ -75,12 +75,12 @@
|
||||
(defn distinct [coll]
|
||||
"Return a generator from the original collection with duplicates
|
||||
removed"
|
||||
(let [[seen []] [citer (iter coll)]]
|
||||
(let [[seen (set)] [citer (iter coll)]]
|
||||
(for* [val citer]
|
||||
(if (not_in val seen)
|
||||
(do
|
||||
(yield val)
|
||||
(.append seen val))))))
|
||||
(.add seen val))))))
|
||||
|
||||
(defn drop [count coll]
|
||||
"Drop `count` elements from `coll` and yield back the rest"
|
||||
|
Loading…
Reference in New Issue
Block a user