Re: grouping and mapping

2016-08-14 Thread Steve Miner
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 "f

Re: grouping and mapping

2016-08-14 Thread miner
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

grouping and mapping

2016-08-14 Thread Nathan Smutz
Just to put the basic Clojure out there: (->> (group-by first foos) (map (fn [[key col]] [key (mapv (comp clojure.string/upper-case second) col)])) (into {}) Kudos to Moe,Christopher and Simon. -- You received this message because you are

Re: grouping and mapping

2016-08-13 Thread Simon Belak
e.get(0), > Collectors.mapping(e -> e.get(1).toUpperCase(), > Collectors.toList(; > > Where the key point is that Collectors.groupingBy accepts a mapping > function in which to map the values being grouped. > > So how would one go abou

Re: grouping and mapping

2016-08-12 Thread Christophe Grand
quot;baz"]]; >> >> foos >> .stream() >> .collect(Collectors.groupingBy(e -> e.get(0), >> Collectors.mapping(e -> e.get(1).toUpperCase(), >> Collectors.toList(; >> >> Where the key point is that Collectors

Re: grouping and mapping

2016-08-12 Thread Moe Aboulkheir
(1).toUpperCase(), > Collectors.toList(; > > Where the key point is that Collectors.groupingBy accepts a mapping > function in which to map the values being grouped. > > So how would one go about writing this in Clojure? I could of-course write > something that ma

grouping and mapping

2016-08-12 Thread Erik Assum
int is that Collectors.groupingBy accepts a mapping function in which to map the values being grouped. So how would one go about writing this in Clojure? I could of-course write something that mapped over the grouped map, but I’d really like to write something like (defn mapping-group-by gr