fn creates an anonymous function.

Syntax

(fn (arg ...) body)

Semantics

  • fn is the standard way to write lambdas in Coalton.
  • A closure is allocated when variables are captured.
  • fn also supports keyword arguments with &key.
  • return may be used to return a value from the function.

Example

(fn (x)
  (+ x 2))