Method Lag
View SourceLag<TSource>(IAsyncEnumerable<TSource>, int)
Produces a projection of a sequence by evaluating pairs of elements separated by a negative offset.
Declaration
public static IAsyncEnumerable<(TSource current, TSource? lag)> Lag<TSource>(this IAsyncEnumerable<TSource> source, int offset)
Parameters
Type | Name | Description |
---|---|---|
IAsyncEnumerable<TSource> | source | The sequence over which to evaluate lag |
int | offset | The offset (expressed as a positive number) by which to lag each value of the sequence |
Returns
Type | Description |
---|---|
IAsyncEnumerable<(TSource current, TSource lag)> | A sequence of tuples with the current and lagged elements |
Type Parameters
Name | Description |
---|---|
TSource | The type of the elements of the source sequence |
Remarks
This operator evaluates in a deferred and streaming manner.
For elements prior to the lag offset, default(TSource
?) is used as the lagged value.
Lag<TSource, TResult>(IAsyncEnumerable<TSource>, int, Func<TSource, TSource?, TResult>)
Produces a projection of a sequence by evaluating pairs of elements separated by a negative offset.
Declaration
public static IAsyncEnumerable<TResult> Lag<TSource, TResult>(this IAsyncEnumerable<TSource> source, int offset, Func<TSource, TSource?, TResult> resultSelector)
Parameters
Type | Name | Description |
---|---|---|
IAsyncEnumerable<TSource> | source | The sequence over which to evaluate lag |
int | offset | The offset (expressed as a positive number) by which to lag each value of the sequence |
Func<TSource, TSource, TResult> | resultSelector | A projection function which accepts the current and lagged items (in that order) and returns a result |
Returns
Type | Description |
---|---|
IAsyncEnumerable<TResult> | A sequence produced by projecting each element of the sequence with its lagged pairing |
Type Parameters
Name | Description |
---|---|
TSource | The type of the elements of the source sequence |
TResult | The type of the elements of the result sequence |
Remarks
This operator evaluates in a deferred and streaming manner.
For elements prior to the lag offset, default(TSource
?) is used as the lagged value.
Lag<TSource, TResult>(IAsyncEnumerable<TSource>, int, TSource, Func<TSource, TSource, TResult>)
Produces a projection of a sequence by evaluating pairs of elements separated by a negative offset.
Declaration
public static IAsyncEnumerable<TResult> Lag<TSource, TResult>(this IAsyncEnumerable<TSource> source, int offset, TSource defaultLagValue, Func<TSource, TSource, TResult> resultSelector)
Parameters
Type | Name | Description |
---|---|---|
IAsyncEnumerable<TSource> | source | The sequence over which to evaluate lag |
int | offset | The offset (expressed as a positive number) by which to lag each value of the sequence |
TSource | defaultLagValue | A default value supplied for the lagged value prior to the lag offset |
Func<TSource, TSource, TResult> | resultSelector | A projection function which accepts the current and lagged items (in that order) and returns a result |
Returns
Type | Description |
---|---|
IAsyncEnumerable<TResult> | A sequence produced by projecting each element of the sequence with its lagged pairing |
Type Parameters
Name | Description |
---|---|
TSource | The type of the elements of the source sequence |
TResult | The type of the elements of the result sequence |
Remarks
This operator evaluates in a deferred and streaming manner.
Lag<TSource, TResult>(IAsyncEnumerable<TSource>, int, TSource, Func<TSource, TSource, ValueTask<TResult>>)
Produces a projection of a sequence by evaluating pairs of elements separated by a negative offset.
Declaration
public static IAsyncEnumerable<TResult> Lag<TSource, TResult>(this IAsyncEnumerable<TSource> source, int offset, TSource defaultLagValue, Func<TSource, TSource, ValueTask<TResult>> resultSelector)
Parameters
Type | Name | Description |
---|---|---|
IAsyncEnumerable<TSource> | source | The sequence over which to evaluate lag |
int | offset | The offset (expressed as a positive number) by which to lag each value of the sequence |
TSource | defaultLagValue | A default value supplied for the lagged value prior to the lag offset |
Func<TSource, TSource, ValueTask<TResult>> | resultSelector | A projection function which accepts the current and lagged items (in that order) and returns a result |
Returns
Type | Description |
---|---|
IAsyncEnumerable<TResult> | A sequence produced by projecting each element of the sequence with its lagged pairing |
Type Parameters
Name | Description |
---|---|
TSource | The type of the elements of the source sequence |
TResult | The type of the elements of the result sequence |
Remarks
This operator evaluates in a deferred and streaming manner.