SICPゼミ第15回
練習問題3.5, 3.6 は乱数生成のやつがなんかうまくいかないので飛ばし。
練習問題3.7
(define (make-joint acc password newpassword) (define (dispatch2 pw m) (if (eq? pw newpassword) (acc password m) (error "Incorrect password"))) (if (= ((acc password 'withdraw) 0) ((acc password 'deposit) 0)) dispatch2 (error "Incorrect password")))
by 現実
練習問題3.8
(define f (let ((val 1)) (lambda (n) (begin (set! val (* val n)) val) ) ) )
実行結果
Racketで実行
> (+ (f 0) (f 1)) 0 > (+ (f 1) (f 0)) 1
by dolicas
練習問題3.9
これ違ってて、横じゃなくて global frame に全部つながる。