Advertisement
konalisp

not lisp

Apr 14th, 2014
97
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.31 KB | None | 0 0
  1. #include <iostream>
  2. #include <functional>
  3. #include <initializer_list>
  4. #define args(x) initializer_list<x>
  5.  
  6. using namespace std;
  7.  
  8. function<int(args(int))> add = [](args(int) arg) -> int{
  9.     int total = 0;
  10.     for(int x : arg)
  11.         total += x;
  12.     return total;
  13. };
  14.  
  15. int main() {
  16.     cout << add({5,4,1,9});
  17.     return 0;
  18. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement