rollup<T, K, R> function

Map<K, R> rollup<T, K, R>(
  1. Iterable<T> iterable,
  2. K key(
    1. T
    ),
  3. R reduce(
    1. List<T>
    )
)

Rolls up elements by a key function and reduces each group.

Implementation

Map<K, R> rollup<T, K, R>(
  Iterable<T> iterable,
  K Function(T) key,
  R Function(List<T>) reduce,
) {
  final groups = group(iterable, key);
  return groups.map((k, v) => MapEntry(k, reduce(v)));
}