runningReduce method

Iterable<E> runningReduce(
  1. E combine(
    1. E value,
    2. E element
    )
)

Returns a Iterable containing successive accumulation values generated by applying combine function from left to right to each element and current accumulator value that starts with the first element of this collection.

Implementation

Iterable<E> runningReduce(E Function(E value, E element) combine) {
  if (isEmpty) return Iterable.empty();

  E value = first;

  return skip(1).map((element) {
    value = combine(value, element);
    return value;
  });
}