18 lines
424 B
C++
18 lines
424 B
C++
#include <vector>
|
|
#include <algorithm>
|
|
#include <iostream>
|
|
|
|
using namespace std;
|
|
|
|
int main() {
|
|
vector<int> ints = {1, 2, 3, 4, 5, 6};
|
|
int total = 0;
|
|
for_each(begin(ints), end(ints), [&total](int x) {
|
|
total += x;
|
|
});
|
|
cout << "total: " << total << endl;
|
|
auto my_lambda_doubling_func = [&](int x) -> int { return x * 2; };
|
|
cout << my_lambda_doubling_func(total) << endl;
|
|
return 0;
|
|
}
|