function | since v0.0-927 | clojure.core/frequencies | Edit |
(frequencies coll)
Returns a map from distinct items in coll
to the number of times they appear.
(frequencies [:a :a :b])
=> {:a 2, :b 1}
Returns a map from distinct items in coll to the number of times they appear.
(defn frequencies
[coll]
(persistent!
(reduce (fn [counts x]
(assoc! counts x (inc (get counts x 0))))
(transient {}) coll)))