Guide
Lambdas & function values
A lambda is a function declaration without the name — one mental model for every function. Captures are by value, and map/filter/fold come built in.
fn make_adder(n: Int) -> fn(Int) -> Int = fn(x: Int) -> Int = x + n
fn main() -> Void:
let add10 = make_adder(10)
print("{add10(32)}")
let words = ["poly", "tone"]
let loud = words.map(fn(w: Text) -> Text = w.upper())
print(loud.join(" + "))$ ptc run lambdas.pt
Recorded output of the real compiler
Function types mirror declarations: fn(Int, Text) -> Bool. Lambdas are fully annotated and expression-bodied, so a signature never requires reading a body. A lambda captures the locals it mentions at creation time, as copies — mutating a capture is a compile error, not a footgun.