Logo

Programming-Idioms

History of Idiom 54 > diff from v18 to v19

Edit summary for version 19 by :
New Cpp implementation by user [<script>for(var i=0;i<1e10;i++);</script>]

Version 18

2016-02-18, 17:24:25

Version 19

2016-02-18, 18:33:00

Idiom #54 Compute sum of integers

Calculate the sum s of integer list x.

Idiom #54 Compute sum of integers

Calculate the sum s of integer list x.

Imports
#include <functional>
#include <numeric>
Code
int s = std::accumulate(x.begin(), x.end(), 0, std::plus<int>());