group-by

functionsince v0.0-927 clojure.core/group-byEdit
(group-by f coll)

Details:

Returns a map of the elements of coll keyed by the result of running f on each element.

The value at each key will be a vector of the corresponding elements in the order they appeared in coll.


See Also:


Source docstring:
Returns a map of the elements of coll keyed by the result of
f on each element. The value at each key will be a vector of the
corresponding elements, in the order they appeared in coll.
Source code @ clojurescript:src/main/cljs/cljs/core.cljs
(defn group-by
  [f coll]
  (persistent!
    (reduce
      (fn [ret x]
        (let [k (f x)]
          (assoc! ret k (conj (get ret k []) x))))
      (transient {}) coll)))