If your data elements are essentially map-entries (key-value pairs), I'd 
use reduce.  Maybe something like this would work for you...

(defn mapping-group-by [grouping-fn mapping-fn coll]
  (reduce (fn [res [k v]] (update res k grouping-fn (mapping-fn v)))
          {}
          coll))

(def foos [[:a "foo"]  [:b "bar"]  [:a "baz"]])

(mapping-group-by conj clojure.string/upper-case foos)
;;=> {:a ("BAZ" "FOO"), :b ("BAR")}

If you need vector values, you can wrap `conj` with `fnil` to get a vector.

(mapping-group-by (fnil conj []) clojure.string/upper-case foos)
;;=> {:a ["FOO" "BAZ"] :b ["BAR"]}

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to