MoreEnumerableAggregateRightTSource, TAccumulate(IEnumerableTSource, TAccumulate, FuncTSource, TAccumulate, TAccumulate) Method

Applies a right-associative accumulator function over a sequence. The specified seed value is used as the initial accumulator value. This operator is the right-associative version of the AggregateTSource, TAccumulate(IEnumerableTSource, TAccumulate, FuncTAccumulate, TSource, TAccumulate) LINQ operator.

Definition

Namespace: MoreLinq
Assembly: MoreLinq (in MoreLinq.dll) Version: 4.1.0+0e154ef592f33ce0f6f3d534a9eedee273f0ce72
C#
public static TAccumulate AggregateRight<TSource, TAccumulate>(
	this IEnumerable<TSource> source,
	TAccumulate seed,
	Func<TSource, TAccumulate, TAccumulate> func
)

Parameters

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.

Type Parameters

TSource
The type of the elements of source.
TAccumulate
The type of the accumulator value.

Return Value

TAccumulate
The final accumulator value.

Usage Note

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).

Remarks

This operator executes immediately.

Example

C#
var numbers = Enumerable.Range(1, 5);
string result = numbers.AggregateRight("6", (a, b) => $"({a}/{b})");
The result variable will contain "(1/(2/(3/(4/(5/6)))))".

See Also