SICP 想到的问题 - joyocaowei/joyocaowei.github.io GitHub Wiki

取消自定义的函数
1 ]=> (cons 1 2)    
;Value: (1 . 2)

1 ]=> (define (cons a b) (+ a b))
;Value: cons

1 ]=> (cons 1 2)
;Value: 3

1 ]=> (unbind-variable (the-environment) 'cons)
;Value: #t

1 ]=> (cons 1 2)
;Value: (1 . 2)
accumulate
;累加器实现  

(define (foo n)
        (lambda (i) (set! n (+ n i)) n))
(define accu (foo 3)) ;这时accu的值为3
(accu 4)              ;value为7
(accu 5)              ;value为12