Skip to content

Instantly share code, notes, and snippets.

@kanwei
Created April 8, 2013 18:37
Show Gist options
  • Save kanwei/5339305 to your computer and use it in GitHub Desktop.
Save kanwei/5339305 to your computer and use it in GitHub Desktop.
Clojure: Remove duplicates via a user-defined function
(defn remove-dups [f coll]
(vals
(reduce (fn [m v]
(let [applied (f v)]
(if-not (contains? m applied)
(assoc m applied v)
m)))
{}
coll)))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment