C++ Ranges proposal for the Standard Library
Walter Bright via Digitalmars-d
digitalmars-d at puremagic.com
Sat Oct 18 10:32:25 PDT 2014
On 10/18/2014 8:17 AM, Andrei Alexandrescu wrote:
> 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
Wow, I hadn't noticed that before. Sweet!
More information about the Digitalmars-d
mailing list