Created
January 8, 2012 02:47
-
-
Save hpcx82/1576945 to your computer and use it in GitHub Desktop.
no loop, no conditional statement, no brute force to print out 1 to 1000
This file contains hidden or 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 <functional> | |
int main() | |
{ | |
std::function<void(int)> a[2]; | |
// lambda: [&capture](parameters)->return_type {body} | |
a[0] = [&](int i) {std::cout << i << std::endl; a[i/1000](i+1);}; | |
a[1] = [](int i) {return;}; | |
a[0](1); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment