groupBy package:foldl

Perform a Fold while grouping the data according to a specified group projection function. Returns the folded result grouped as a map keyed by the group.