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