Folds the elements of this sequence using the specified accumulator function.
If this sequence represents an infinite set or series, this will never return!
Namespace: SequencesAssembly: Sequences (in Sequences.dll) Version: 1.0.1.0 (1.0.1)
Syntax
Parameters
- seed
- Type: T
The initial accumulator value. A neutral value for the fold operation (e.g., empty list, or 0 for adding the elements of this sequence, or 1 for multiplication).
- op
- Type: System Func T, T, T
A function that takes the accumulator and an element of this sequence, and computes the new accumulator.
Return Value
Type: TThe result of applying op between all the elements and seed.
Examples
int sum = Sequence.With(1,2,3,4).Fold(0, (a, b) => a + b);
See Also