ImmutableArrayExtensions.Aggregate Method (System.Linq) (original) (raw)
Source:
Source:
Source:
Source:
Source:
Applies a function to a sequence of elements in a cumulative way.
public:
generic <typename TAccumulate, typename TResult, typename T>
[System::Runtime::CompilerServices::Extension]
static TResult Aggregate(System::Collections::Immutable::ImmutableArray<T> immutableArray, TAccumulate seed, Func<TAccumulate, T, TAccumulate> ^ func, Func<TAccumulate, TResult> ^ resultSelector);
public static TResult Aggregate<TAccumulate,TResult,T>(this System.Collections.Immutable.ImmutableArray<T> immutableArray, TAccumulate seed, Func<TAccumulate,T,TAccumulate> func, Func<TAccumulate,TResult> resultSelector);
static member Aggregate : System.Collections.Immutable.ImmutableArray<'T> * 'Accumulate * Func<'Accumulate, 'T, 'Accumulate> * Func<'Accumulate, 'Result> -> 'Result
<Extension()>
Public Function Aggregate(Of TAccumulate, TResult, T) (immutableArray As ImmutableArray(Of T), seed As TAccumulate, func As Func(Of TAccumulate, T, TAccumulate), resultSelector As Func(Of TAccumulate, TResult)) As TResult
Type Parameters
TAccumulate
The type of the accumulated value.
TResult
The type of result returned by the result selector.
T
The type of element contained by the collection.
Parameters
seed
TAccumulate
The initial accumulator value.
func
Func<TAccumulate,T,TAccumulate>
A function to be invoked on each element, in a cumulative way.
resultSelector
Func<TAccumulate,TResult>
A function to transform the final accumulator value into the result type.
Returns
TResult
The final accumulator value.
Remarks
Aggregate method makes it simple to perform a calculation over a sequence of values. This method works by calling func
one time for each element in source. Each time func
is called, Aggregate passes both the element from the sequence and an aggregated value (as the first argument to func). The value of the seed
parameter is used as the initial aggregate value. The result of func
replaces the previous aggregated value. Aggregate returns the final result of func
.