// Collection of code snippets by Arne Vajhøj 
// (likely posted to comp.os.vms/INFO-VAX, INFO-TPU, MACRO32, eksperten.dk, newz.dk, LinkedIn or other place sometime between 1990 and now) 
#include <iostream>
#include <vector>
#include <numeric>

using std::vector;
using std::cout;
using std::endl;
using std::reduce;
using std::plus;

int sum1(vector<int> v)
{
    return reduce(v.cbegin(), v.cend(), 0, plus<>());
}

int sum2(vector<int> v)
{
    int sum = 0;
    for(int i = 0; i < v.size(); i++) sum += v[i];
    return sum;
}

int main()
{
    vector<int> v = { 1, 2, 3 };
    cout << sum1(v) << endl;
    cout << sum2(v) << endl;
    return 0;
}
