• (group-by f coll)
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.

0 Examples top

Log in to add / edit an example.

See Also top

Log in to add a see also.

Plus_12x12 Minus_12x12 Source clojure/contrib/seq.clj:61 top

(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))
Vars in clojure.contrib.seq/group-by: assoc conj defn fn get group-by let reduce sorted-map
Used in 0 other vars

Comments top

No comments for group-by. Log in to add a comment.