(frequencies coll)
Returns a map from distinct items in coll to the number of times they appear.
user=> (frequencies ['a 'b 'a 'a])
{a 3, b 1}
;; Turn a frequency map back into a coll.
(mapcat (fn [[x n]] (repeat n x)) {:a 2 :b 1 :c 3})
;;=> (:a :a :b :c :c :c)