λ Lambdas λ

Lambdas

smalldragon now supports Lambdas (Anonymous Functions) as subroutine arguments as an experimental feature.
Lambdas are currently not first-class, they cannot be assigned to variables.

the situation may improve in the future.

Syntax

(arg_1, ..., arg_n) -> Expr

Limitations

Use Case

You have a subroutine, e.g. subr, accepting a subroutine f as an argument,
and the computation (x) -> x + 1
you want to express is fairly short and does not need it's own named subroutine.

Example

fn main () ~> int {
	return subr( (x) -> x+1, 8 );
}

fn subr ( ((int)->int) f, k) -> int {
	return f(k);
}