foldRight method
R
foldRight(
- R callback(
- R left,
- S seperator,
- R right
Combines the elements by grouping the elements from the right and
calling callback on all consecutive elements with the corresponding
separator.
For example, if the elements are numbers and the separators are
exponentiation operations sequential values 1 ^ 2 ^ 3 are grouped like
1 ^ (2 ^ 3).
Implementation
R foldRight(R Function(R left, S seperator, R right) callback) {
var result = elements.last;
for (var i = elements.length - 2; i >= 0; i--) {
result = callback(elements[i], separators[i], result);
}
return result;
}