Logo

Programming-Idioms

History of Idiom 54 > diff from v43 to v44

Edit summary for version 44 by WHS:
[C++] One of these parameters is not stricly needed.

Version 43

2020-11-21, 14:46:36

Version 44

2020-12-24, 16:45:36

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.

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