learning-sicp

My embarrassing half assed SICP run.
git clone https://kaka.farm/~git/learning-sicp
Log | Files | Refs

exercise-2.scm (477B)


      1 (define-library (sicp solutions chapter-3 exercise-2)
      2   (import (scheme base))
      3   (export make-monitored)
      4 
      5   (begin
      6     (define (make-monitored proc)
      7       (define number-of-calls 0)
      8       
      9       (lambda (input)
     10         (cond
     11          ((eq? input 'how-many-calls?)
     12           number-of-calls)
     13          ((eq? input 'reset-count)
     14           (set! number-of-calls 0))
     15          (else
     16           (set! number-of-calls
     17                 (+ 1 number-of-calls))
     18           (proc input)))))))