logoalt Hacker News

mpyneyesterday at 2:51 PM2 repliesview on HN

C++ has std::reduce for that, which is std::accumulate except it's defined to operate without any specific ordering.


Replies

rzzztyesterday at 3:11 PM

Thanks everyone, my C++ knowledge has been greatly expanded today.

Joker_vDyesterday at 5:35 PM

And now you should probably also stop and consider whether adding elements one-by-one as opposed to recursively adding together sums of smaller subarrays has better or worse numerical behaviour in regards to e.g. rounding and stability.