Aggregation Using merge-with
Clojure provides the merge-with
function as a way of conjoining a series of maps. You must provide merge-with
a function that it can use to merge two values for matching keys. For instance, imagine you have a bunch of maps that contain counts for entities identified by keywords. You can consolidate the sum of all the counts into a single map using the merge-with
function combined with the +
function.
For different kinds of data, a different function argument may be more appropriate. For instance, aggregating lists instead of integers calls for the concat
function:
Last updated