DEPRECATED. Prefer clojure.core version.
Returns a sorted 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.
(defn group-by
"DEPRECATED. Prefer clojure.core version.
Returns a sorted 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."
{:deprecated "1.2"}
[f coll]
(reduce
(fn [ret x]
(let [k (f x)]
(assoc ret k (conj (get ret k []) x))))
(sorted-map) coll))
Comments top
No comments for group-by. Log in to add a comment.