C++ Ranges proposal for the Standard Library
Andrei Alexandrescu via Digitalmars-d
digitalmars-d at puremagic.com
Sat Oct 18 08:17:09 PDT 2014
On 10/18/14, 4:43 AM, John Colvin wrote:
> auto kahanSum(R)(R input)
> {
> double sum = 0.0;
> double c = 0.0;
> foreach(double el; input)
> {
> double y = el - c;
> double t = sum + y;
> c = (t - sum) - y;
> sum = t;
> }
> return sum;
> }
No need to implement it. http://dlang.org/phobos/std_algorithm.html#.sum
Andrei
More information about the Digitalmars-d
mailing list