fold<R> method
R
fold<R>(
- R initial,
- R operation(
- R acc,
- T
Accumulates value starting with initial
value and applying operation
from left to right to current accumulator value and each element.
Implementation
R fold<R>(R initial, R Function(R acc, T) operation) {
var accumulator = initial;
for (final element in iter) {
accumulator = operation(accumulator, element);
}
return accumulator;
}