[Issue 4725] std.algorithm.sum()
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Wed Mar 13 11:46:49 PDT 2013
http://d.puremagic.com/issues/show_bug.cgi?id=4725
--- Comment #18 from bearophile_hugs at eml.cc 2013-03-13 11:46:47 PDT ---
(In reply to comment #17)
> https://github.com/D-Programming-Language/phobos/pull/1205
In the patch this the code used to sum in the general case:
+ Result seed = 0;
+ return reduce!"a + b"(seed, r);
Beside the idea in Issue 7934 , I suggest to add a "static if" that tests if
the input is an array (or a random access range) and in such case instead of
reduce uses a loop like this:
for (int i = 2; i < stop; i += 2) {
total += array[i];
total2 += array[i + 1];
}
--
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
More information about the Digitalmars-d-bugs
mailing list