Version: 1.1.0

Lambda expressions reference

Grammar for a one-expression function.

Essentials

  • Arguments can be typed or untyped.
  • The body is one expression, not a block.
  • A trailing type comment is not a return type. Write -> when you need one.
  • Lambdas participate in captures.

Example

def main():
    var square = lambda x: x * x
    print(square(9))

Keep in mind

Do not nest lambdas. Name the inner function.