Summary
Applies an accumulator function over an async sequence, returning the result of the aggregation as a single element in the result sequence. The specified seed value is used as the initial accumulator value.
For aggregation behavior with incremental intermediate results.
Syntax
public static ValueTask<TAccumulate> ReduceAsync<TSource, TAccumulate>(this IAsyncEnumerable<TSource> source, TAccumulate seed, Func<TAccumulate, TSource, TAccumulate> accumulator)
The return type of this operator differs from the corresponding operator on IAsyncEnumerable in order to retain asynchronous behavior.
Type Parameters
Name |
Description |
TSource |
The type of the elements in the source sequence. |
TAccumulate |
The type of the result of the aggregation. |
Parameters
Name |
Type |
Description |
source |
IAsyncEnumerable<TSource> |
An async sequence to aggregate over. |
seed |
TAccumulate |
The initial accumulator value. |
accumulator |
Func<TAccumulate, TSource, TAccumulate> |
An accumulator function to be invoked on each element. |
Return Value
Type |
Description |
ValueTask<TAccumulate> |
An async sequence containing a single element with the final accumulator value. |