Method Scan
View SourceScan<TSource>(IAsyncEnumerable<TSource>, Func<TSource, TSource, TSource>)
Performs a scan (inclusive prefix sum) on a sequence of elements. This operator is similar to Aggregate<TSource>(IEnumerable<TSource>, Func<TSource, TSource, TSource>) except that Scan<TSource>(IAsyncEnumerable<TSource>, Func<TSource, TSource, TSource>) returns the sequence of intermediate results as well as the final one.
Declaration
public static IAsyncEnumerable<TSource> Scan<TSource>(this IAsyncEnumerable<TSource> source, Func<TSource, TSource, TSource> transformation)
Parameters
Type | Name | Description |
---|---|---|
IAsyncEnumerable<TSource> | source | Source sequence |
Func<TSource, TSource, TSource> | transformation | Transformation operation |
Returns
Type | Description |
---|---|
IAsyncEnumerable<TSource> | The scanned sequence |
Type Parameters
Name | Description |
---|---|
TSource | Type of elements in source sequence |
Remarks
This operator uses deferred execution and streams its result.
Exceptions
Type | Condition |
---|---|
ArgumentNullException |
|
Scan<TSource, TState>(IAsyncEnumerable<TSource>, TState, Func<TState, TSource, TState>)
Performs a scan (inclusive prefix sum) on a sequence of elements. This operator is similar to Aggregate<TSource, TAccumulate>(IEnumerable<TSource>, TAccumulate, Func<TAccumulate, TSource, TAccumulate>) except that Scan<TSource, TState>(IAsyncEnumerable<TSource>, TState, Func<TState, TSource, TState>) returns the sequence of intermediate results as well as the final one.
Declaration
public static IAsyncEnumerable<TState> Scan<TSource, TState>(this IAsyncEnumerable<TSource> source, TState seed, Func<TState, TSource, TState> transformation)
Parameters
Type | Name | Description |
---|---|---|
IAsyncEnumerable<TSource> | source | Source sequence |
TState | seed | Initial state to seed |
Func<TState, TSource, TState> | transformation | Transformation operation |
Returns
Type | Description |
---|---|
IAsyncEnumerable<TState> | The scanned sequence |
Type Parameters
Name | Description |
---|---|
TSource | Type of elements in source sequence |
TState | Type of state |
Remarks
This operator uses deferred execution and streams its result.
Exceptions
Type | Condition |
---|---|
ArgumentNullException |
|