fork(2) download
  1. #include <iostream>
  2. #include <functional>
  3.  
  4. int main()
  5. {
  6. std::function<long(int)> lambda = [&](int x) -> long {
  7. if (x != 0)
  8. return x+lambda(x-1);
  9. else
  10. return 0;
  11. };
  12. std::cout << lambda(20) << std::endl;
  13. return 0;
  14. }
Success #stdin #stdout 0s 3456KB
stdin
Standard input is empty
stdout
210