Performs a reduction operation on the elements of this seq. This is equivalent to:
G? result = null;
bool found = false;
foreach (G g in seq) {
if (!found) {
result = g;
found = true;
} else {
result = accumulator(g, result);
}
}
return found ? new Optional<G>.of(result) : new Optional<G>.empty();
but is not constrained to execute sequentially.
This is a terminal operation.
accumulator |
an associative, non-interfering, and stateless function for combining two values |
a future of the result of the reduction |