mergeIterable<I, R> function

R? mergeIterable<I, R>(
  1. Iterable<I> iterable,
  2. R merge(
    1. R? total,
    2. I value
    ), [
  3. R? init
])

Merges all entries of iterable using merge function.

init The initial value of total.

Implementation

R? mergeIterable<I, R>(
    Iterable<I> iterable, R Function(R? total, I value) merge,
    [R? init]) {
  if (iterable.isEmpty) return init;

  var total = init;

  for (var entry in iterable) {
    total = merge(total, entry);
  }

  return total;
}