SICP

it2024-11-12  13

1 ;;;;;;;;;;;3.1 2 3 (define (make-accumulator base) 4 (lambda (num) 5 (set! base (+ base num)) 6 base)) 7 8 (define A (make-accumulator 5)) 9 10 (A 10) 11 (A 10) 12 13 ;;;;;;;;;;3.2 14 15 (define (make-monitored f) 16 (let ((count 0)) 17 (define (mf x) 18 (cond ((eq? x 'how-many-calls?) count) 19 ((eq? x 'reset-count) (set! count 0)) 20 (else (begin (set! count (+ count 1)) 21 (f x))))) 22 mf)) 23 24 (define square (lambda (x) (* x x))) 25 (define s (make-monitored square)) 26 27 (s 100) 28 (s 4) 29 (s 'how-many-calls?) 30 (s 'reset-count) 31 (s 'how-many-calls?)

 

先跳过了一些,等3.2后再看

 

开始用完全用Scheme来写

 

开始用Linux系统

 

转载于:https://www.cnblogs.com/tclan126/p/6523621.html

最新回复(0)