]> git.rkrishnan.org Git - sicp.git/blob - src/sicp/ex4_13.rkt
Solution to 4.33. This had been difficult to get right, though conceptually it was
[sicp.git] / src / sicp / ex4_13.rkt
1 #lang racket
2
3 (define (make-unbound! var val env)
4   (let ((frame (first-frame env)))
5     (define (scan vars vals)
6       (cond ((null? vars)
7              (error "variable not bound" var))
8             ((eq? var (car vars))
9              (begin
10                (set-car! vals (cdr vals))
11                (set-cdr! vars (cdr vars))))
12             (else (scan (cdr vars) (cdr vals)))))
13     (scan (frame-variables frame)
14           (frame-values frame))))
15
16 #|
17
18 Remove binding from the first frame, as removing it from elsewhere
19 would mean also removing all bindings built from it.
20
21 |#