Lambda Functions
Now, we'll study a special type of function: the lambda.
We'll cover the following...
We'll cover the following...
A lambda function, or lambda, is a function without a name.
A lambda can be written in-place and doesn’t require complete implementation outside the scope of the main program.
A cool feature of lambdas is that they can be treated as data. Hence, they can be stored or copied in variables.
Syntax #
[]: Captures the used variables.(): Necessary for parameters.->: Necessary for complex lambda functions.{}: Function body, per defaultconst.[]() mutable -> {...}has a non-constant function body.
What exactly do we mean by capture?