Local Bindings

;; let: parallel bindings
(let ((x 2) (y 3))
  (* x y))                            ; 6

(let ((x 1))
  (let ((x 10) (y x))                 ; y sees the OUTER x
    (+ x y)))                         ; 11

;; let*: sequential bindings
(let* ((x 2) (y (* x 10)))
  (+ x y))                            ; 22

;; letrec / letrec*: recursive bindings
(letrec ((even? (lambda (n) (if (= n 0) #t (odd? (- n 1)))))
         (odd?  (lambda (n) (if (= n 0) #f (even? (- n 1))))))
  (even? 100))                        ; #t

;; named let: a local recursive procedure (the standard loop idiom)
(let loop ((i 0) (acc '()))
  (if (= i 5)
      (reverse acc)
      (loop (+ i 1) (cons (* i i) acc))))   ; (0 1 4 9 16)

;; let-values / let*-values: bind multiple values (Module 24)
(let-values (((q r) (floor/ 17 5)))
  (list q r))                         ; (3 2)

;; Under the hood: let is syntactic sugar for lambda application
;; (let ((x 1) (y 2)) body)  ≡  ((lambda (x y) body) 1 2)