Skip to content
Giorgio Garofalo edited this page Oct 11, 2024 · 6 revisions

A lambda is a block of code that maps a variable amount of parameters into a single output value of any type (see the Value types section of this wiki).

Its syntax is:

param1 param2 param3:
My code

Where param1 param2 param3: is the header of the lambda, where parameter names are defined. Their values can be accessed as if you were dealing with variables:

param1 param2 param3:
The second parameter is .param2

The header can be omitted:

  • If the lambda expects 0 parameters (e.g. conditional statements)
  • In any other case, the parameters become implicit and can be accessed by position via .1, .2, .3, etc.
The second parameter is .2

Example: .foreach

.foreach {2..5}
  n:
  The number is **.n**

With implicit parameter:

.foreach {2..5}
  The number is **.1**

Example: .function

.function's body is a lambda that accepts a variable amount of explicit parameters:

.function {area}
  width height:
  .multiply {width} by:{height}

Clone this wiki locally