News for hackers. Stuff that matters.
Re:Lambda-style anonymous functions for C++ in less than 500... by Jach on Tuesday April 13, 2010 @12:49PM (#1262552)
What are you talking about? You're missing an arg in your transform() call.

  int nums[] = {1, 2, 3};
  printf("nums: %i %i %i\n", nums[0], nums[1], nums[2]);
  std::transform(nums, nums+3, nums, (lambda<int> (x) --> 2*x));
  printf("new nums: %i %i %i\n", nums[0], nums[1], nums[2]);
Edit: And of course, there's the implemented map he gives in the example:

  int* incs = (lambda<int> (x) --> x + 1).map(3,nums);
The class needs a little bit of work obviously (like more operators overloaded), but it's pretty nice.

There are no comments on this comment yet.