ReduceBack

Applies the reduction function to each element of the collection, starting from the end, threading an accumulator argument through the computation.

Parameters

Returns

Func<T, T, T> reduction

IEnumerable<T> source

TState

Usage

Accumulating a subtraction of each element in a collection

//IEnumerable<int> source = 
//    { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 }

int result = source.ReduceBack( 
       (accumulator, element) => element - accumulator

//result = 5

Last updated