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
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
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
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
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
(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
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