Anonymous Functions/Lambdas

Lambdas are the namesake of lambda calculus, which is what Marigold is built off of. Lambdas are known as anonymous functions because they act like regular functions but without names. Every data type in Marigold is secretly a lambda:

Usage

A lambda is comprised of local variables and a term. You can think of a lambda like this:

@x.x+1

is equivalent to

def add(x) { x + 1; }

Currying

Lambdas technically only takes in one input, but Marigold will automatically curry them, meaning:

@ab.a+b

is just shorthand for

@a.@b.a+b

Example

Lambdas are very useful when it comes to mapping and pipelines!

See also