Fold
Successively applies the given function to the members of the sequence.
Syntax
Sequence.Fold
· [sequence]
· [func]
Parameters
- sequence
- The sequence to fold.
- func
- An accumulator function that receives two values and returns a new value, all of them having the same type as the members of the sequence.
Return Value
A sequence containing the result of applying the given function to the members of the sequence, or an empty sequence if the original sequence was empty.
Remarks
This function works by first calling func
and passing the first and second members of the sequence. Then, it passes the result and the third member of the sequence, and repeats this process until it reaches the last member.