Here's a function and a simple use of it. It works, but the code may not be good Clojure. I'm wondering how it might be better.
(defn distinct-by
"Returns a sequence with no repeats of (f item).
A set is built up internally as the sequence is consumed, so don't use it on
an infinite sequence or you will run out of memory."
([f coll]
(letfn [(get-more [seen input-seq]
(if (not (empty? input-seq))
(let [x (first input-seq)
fx (f x)]
(if (contains? seen fx)
(lazy-seq (get-more seen (rest input-seq)))
(lazy-seq (cons x (get-more (conj seen fx) (rest input-seq))))))))]
(get-more #{} (seq coll)))))
(def xs (list {:n 1, :a 'a} {:n 2, :a 'b} {:n 3, :a 'a} {:n 4, :a 'c} {:n 5, :a 'b}))
(distinct-by :a xs)
=> ({:n 1, :a a} {:n 2, :a b} {:n 4, :a c})
Rob