Lambda Functions

Now, we'll study a special type of function: the lambda.

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 #

widget
  • []: Captures the used variables.
  • (): Necessary for parameters.
  • ->: Necessary for complex lambda functions.
  • {}: Function body, per default const.
    • []() mutable -> {...} has a non-constant function body.
...