Skip to content

Instantly share code, notes, and snippets.

@hpcx82
Created January 8, 2012 02:47
Show Gist options
  • Save hpcx82/1576945 to your computer and use it in GitHub Desktop.
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
#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