The best I could come up with was:
(defn dups [seq]
(map (fn [[id freq]] id)
(filter (fn [[id freq]] (> freq 1))
(frequencies seq))))
Is there a more concise way?
Sequences are guaranteed to generate sequential values (to the ending limit). More likely, something else is inserting values ahead of the sequence, so there are "duplicates" by the time the sequence reaches those values.
Oracle sequences are guaranteed not to generate duplicate values.
When duplicates are removed, the first occurrence of the value in the list is kept, but other identical values are deleted. Because you are permanently deleting data, it's a good idea to copy the original range of cells or table to another worksheet or workbook before removing duplicate values.
Use a list comprehension:
(defn dups [seq]
(for [[id freq] (frequencies seq) ;; get the frequencies, destructure
:when (> freq 1)] ;; this is the filter condition
id)) ;; just need the id, not the frequency
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With