Enumerable.Scan extension method
It implements a function commonly known as scanl which returns the intermediate result of aggregations.
```c#
var nums = new [] { 1, 2, 3, 4, 5 };
var sums = nums.Scan(0, (x,y) => x + y);
/// sums is [1, 3, 6, 10, 15]
```
MODIFY
WalletWasabi/Extensions/LinqExtensions.cs
WalletWasabi/Extensions/LinqExtensions.cs
@@ -193,5 +193,19 @@ namespace System.Linq
}
return source.Zip(otherCollection);
}
+
+ public static IEnumerable<TAccumulate> Scan<TSource, TAccumulate>(
+ this IEnumerable<TSource> source,
+ TAccumulate seed,
+ Func<TAccumulate, TSource, TAccumulate> func)
+ {
+ TAccumulate previous = seed;
+ foreach (var item in source)
+ {
+ var result = func(previous, item);
+ previous = result;
+ yield return result;
+ }
+ }
}
}

Enumerable.Scan extension method

It implements a function commonly known as scanl which returns the intermediate result of aggregations.

```c#
var nums = new [] { 1, 2, 3, 4, 5 };
var sums = nums.Scan(0, (x,y) => x + y);
/// sums is [1, 3, 6, 10, 15]
```