MoreEnumerableScanRightTSource, TAccumulate(IEnumerableTSource, TAccumulate, FuncTSource, TAccumulate, TAccumulate) Method
Namespace: MoreLinqAssembly: MoreLinq (in MoreLinq.dll) Version: 4.4.0+6d97c3b1d482f98300f4446df14742b0e3fafbec
public static IEnumerable<TAccumulate> ScanRight<TSource, TAccumulate>(
this IEnumerable<TSource> source,
TAccumulate seed,
Func<TSource, TAccumulate, TAccumulate> func
)
<ExtensionAttribute>
Public Shared Function ScanRight(Of TSource, TAccumulate) (
source As IEnumerable(Of TSource),
seed As TAccumulate,
func As Func(Of TSource, TAccumulate, TAccumulate)
) As IEnumerable(Of TAccumulate)
public:
[ExtensionAttribute]
generic<typename TSource, typename TAccumulate>
static IEnumerable<TAccumulate>^ ScanRight(
IEnumerable<TSource>^ source,
TAccumulate seed,
Func<TSource, TAccumulate, TAccumulate>^ func
)
[<ExtensionAttribute>]
static member ScanRight :
source : IEnumerable<'TSource> *
seed : 'TAccumulate *
func : Func<'TSource, 'TAccumulate, 'TAccumulate> -> IEnumerable<'TAccumulate>
- source IEnumerableTSource
- Source sequence.
- seed TAccumulate
- The initial accumulator value.
- func FuncTSource, TAccumulate, TAccumulate
- A right-associative accumulator function to be invoked on each element.
- TSource
- The type of the elements of source.
- TAccumulate
- The type of the accumulator value.
IEnumerableTAccumulateThe scanned sequence.In Visual Basic and C#, you can call this method as an instance method on any object of type
IEnumerableTSource. When you use instance method syntax to call this method, omit the first parameter. For more information, see
Extension Methods (Visual Basic) or
Extension Methods (C# Programming Guide).
This operator uses deferred execution and streams its results.
Source sequence is consumed greedily when an iteration of the resulting sequence begins.
var result = Enumerable.Range(1, 4).ScanRight("5", (a, b) => $"({a}+{b})");
The
result variable will contain
[ "(1+(2+(3+(4+5))))", "(2+(3+(4+5)))", "(3+(4+5))", "(4+5)", "5" ].