From the course: Introducing Functional Programming in C++

Unlock the full course today

Join today to access over 22,600 courses taught by industry experts or purchase this course individually.

Lambda functions: Curry

Lambda functions: Curry - C++ Tutorial

From the course: Introducing Functional Programming in C++

Start my 1-month free trial

Lambda functions: Curry

- [Instructor] Lambdas were introduced to the language with C++11, they are unnamed function objects which can create a closure over the invoking scope. Let's write some code to learn more about lambdas. We already have this file set up, we have some code down here inside of our main function, and this is just going to render the results once we're ready for it. We have our include and using already set up, and we're going to create an auto variable called addCurry, and we're going to set this equal to auto a, and this is going to be our lambda. And then it is going to return, and right here in our capture list, we're going to put the a, and this means that we want to be able to access a from our inner lambda, and then we're going to have a parameter list, and that's going to be b. Then b is also going to return, and what it's going to return is another lambda, and so inside of the capture list for the b, we're going to put a and b, 'cause we're want them both. Then we're going to…

Contents