You're viewing version 1.2.0 of frequencies. The latest stable version of Clojure Core is 1.3.0.
1.2.0 Arrow_down_16x16

frequencies

clojure.core

  • (frequencies coll)
Returns a map from distinct items in coll to the number of times
they appear.

1 Example top

  • user=> (frequencies ['a 'b 'a 'a])
    {a 3, b 1}
Log in to add / edit an example.

See Also top

Log in to add a see also.

Plus_12x12 Minus_12x12 Source clojure/core.clj:5566 top

(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)))
Vars in clojure.core/frequencies: assoc! defn fn get inc persistent! reduce transient
Used in 2 other vars frequencies frequencies

Comments top

No comments for frequencies. Log in to add a comment.