26-let.scm (663B)
1 ;; Step 12b: let / let* / letrec. 2 ;; letrec must pre-bind all names so mutually recursive bindings can 3 ;; see each other — this is the key behavior that distinguishes it 4 ;; from let*. 5 (if (= (let ((x 5) (y 7)) (+ x y)) 12) 6 (if (= (let* ((x 5) (y (+ x 3))) y) 8) 7 (if (= (letrec ((f (lambda (n) 8 (if (< n 2) 1 (* n (f (- n 1))))))) 9 (f 5)) 120) 10 (if (= (letrec ((even? (lambda (n) 11 (if (= n 0) 1 (odd? (- n 1))))) 12 (odd? (lambda (n) 13 (if (= n 0) 0 (even? (- n 1)))))) 14 (+ (even? 4) (odd? 7))) 2) 15 42 0) 0) 0) 0)