using LINQ to find the cumulative sum of an array of numbers in C#
There’s a time for generality, and there’s a time for solving the problem actually posed. This is one of the latter times. If you want to make a method that turns a sequence of doubles into a sequence of partial sums, then just do that: public static IEnumerable<double> CumulativeSum(this IEnumerable<double> sequence) { double sum = … Read more