scan<R> method

List<R> scan<R>(
  1. R initial,
  2. R combine(
    1. R,
    2. T
    )
)

List of initial and each step of combine(acc, element).

Implementation

List<R> scan<R>(R initial, R Function(R, T) combine) {
  final List<R> out = <R>[initial];
  R acc = initial;
  for (final T e in this) {
    acc = combine(acc, e);
    out.add(acc);
  }
  return out;
}