-
Notifications
You must be signed in to change notification settings - Fork 4
let
Turtle Kitty edited this page Jan 29, 2016
·
5 revisions
This opens a new scope with new variables.
(let (arg1 val1 ...) body ...) is syntactic sugar for ((λ (arg1 arg2 ...) body ...) val1 val2 ...).
(let (x 1 y 2)
...)
-> ((λ (x y) ...) 1 2)
A let operator can have a label, allowing for recursion without adding a name to the enclosing environment.
(def things '(1 2 3))
(let loop (x things.head xs things.tail acc ())
(if xs
(loop xs.head xs.tail (acc.cons x))
(acc.cons x)))
-> (3 2 1)