Sequence T  Fold Method A Sandcastle Documented Class Library
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: Sequences
Assembly: Sequences (in Sequences.dll) Version: 1.0.1.0 (1.0.1)
Syntax
public T Fold(
	T seed,
	Func<T, T, T> op
)

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: T
The result of applying op between all the elements and seed.

Implements

ISequence T  Fold(T, Func T, T, T )
Examples
int sum = Sequence.With(1,2,3,4).Fold(0, (a, b) => a + b);
See Also