let Family in Scheme
The let family in Scheme programming language. They are used to bind values to variables.
Table of Contents
1. let: Parallel Binding
The bindings are parallel, i.e., latter bindings cannot use other bindings.
2. let*: Sequential Binding
Latter bindings can use priorly defined bindings.
(let* ((x 1)
(y (+ x 1))))
3. letrec
4. Named let
I think it’s easier to think of it as “we define a function using let”. And we can call this function in the body.
Named let are often used to create loops.
(let loop ((i 0) (acc 0))
(if (= i 5)
acc
(loop (+ i 1) (+ acc i))))