Nothing special just to make sure to call mf in the block of let.
Otherwise,the value of counter cannot be set correctly
没有什么难度,但是要注意一定要在let的内部调用mf。
否则,counter的值不正确。
難しくないですが、letの内部でmf関数をコールすること。
でもないと、counterの値が正しく保持されてない。
(define (make-monitored f)
(let ((counter 0))
(define (mf m)
(cond ((eq? m 'how-many-calls) counter)
((eq? m 'reset-count) (set! counter 0))
(else (set! counter (+ counter 1)) (f m))))
mf))
No comments:
Post a Comment