Created
March 30, 2012 21:16
-
-
Save shintakezou/2255145 to your computer and use it in GitHub Desktop.
lambda in C++11
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
#include <numeric> | |
#include <vector> | |
using namespace std; | |
int main() | |
{ | |
vector<int> array = {1, 2, 3, 4, 5}; | |
int r = accumulate(array.begin(), array.end(), 0, | |
[](const int& x, const int& y) -> int { return x + y*2; }); | |
cout << r << endl; | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment