Casting MapResult

Ali Çehreli via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Mon Jun 15 09:47:36 PDT 2015


On 06/15/2015 09:39 AM, "Marc =?UTF-8?B?U2Now7x0eiI=?= 
<schuetzm at gmx.net>" wrote:

>>     writeln(y.sum);    // same as sum(y)
>> }
>>
>> An equivalent of the last line:
>>
>>     writeln(reduce!((result, a) => result + a)(y));

> `sum` is better for floating-point ranges, because it uses pair-wise or
> Kahan summation if possible, in order to preserve precision.

Good point. I had mentioned that elsewhere after learning about it 
recently: "the sum of the elements of a range should be calculated by 
std.algorithm.sum, which uses special algorithms to achieve more 
accurate calculations for floating point types." :)

   http://ddili.org/ders/d.en/fibers.html#ix_fibers.recursion

Ali



More information about the Digitalmars-d-learn mailing list