2 ms·
as a note, the source is: (defn frequencies "Returns a map from distinct items in coll to the number of times they appear." {:added "1.2"} [coll] (pe
by Avshalom 16y ago
as a note, the source is:
(defn frequencies
"Returns a map from distinct items in coll to the number of times they appear."
{:added "1.2"}
[coll]
(persistent!
(reduce (fn [counts x]
(assoc! counts x (inc (get counts x 0))))
(transient {}) coll)))
which I think is pretty much just Raphael's solution.