Functions are closures that capture their lexical environment and are first class. They can be passed around like any other variable. For example:
fn adder(x) { fn (y) { x + y } } define add2 = adder(2); define add3 = adder(3); add2(3); // 5 add3(3); // 6
The inner anonymous function returned by adder captures the argument value of x and when later invoked adds that to its argument y.
adder
x
y
Up: Functions
Next: Currying
There was an error while loading. Please reload this page.
fn