foldRight<R> method
R
foldRight<R>(
- R initial,
- R operation(
- T,
- R acc
Accumulates value starting with initial
value and applying operation
from right to left to each element and current accumulator value.
Implementation
R foldRight<R>(R initial, R Function(T, R acc) operation) {
if (isEmpty()) return initial;
var accumulator = initial;
final i = listIterator(size);
while (i.hasPrevious()) {
accumulator = operation(i.previous(), accumulator);
}
return accumulator;
}