13 lines
297 B
Racket
13 lines
297 B
Racket
#lang sicp
|
|
|
|
(define (make-monitored f)
|
|
(let ((call-count 0))
|
|
(define (mf arg)
|
|
(cond ((eq? arg 'how-many-calls?) call-count)
|
|
((eq? arg 'reset-count) (set! call-count 0))
|
|
(else
|
|
(set! call-count (+ call-count 1))
|
|
(f arg))))
|
|
mf))
|
|
|