1.练习2.73
a
没有必要
b
(define (insert-sum-proc)
(define (deriv-sum exp var)
(make-sum (deriv (car exp) var)
(deriv (cadr exp) var)))
(put 'deriv '+ deriv-sum)
'done)
(define (insert-mult-proc)
(define (deriv-mult exp var)
(make-sum
(make-product (car exp)
(deriv (cadr exp) var))
(make-product (deriv (car exp) var)
(cadr exp))))
(put 'deriv '* deriv-mult)
'done)
c
d
改变put和get的顺序
2.练习2.74
a
;;提供分支机构的名称,即brcanch
(define (get-record branch name)
(cond ((null? branch) false)
((null? name) false)
(else ((get 'get-record branch) name))))
b
;;提供分支机构的名称,即brcanch
(define (get-salary branch name)
(cond ((null? branch) false)
((null? name) false)
(else ((get 'get-salary branch) name))))
c
(define (find-employee-record name branchs)
(if (null? branchs)
false
(let ((record ((get 'get-record (branch-name (car branchs))) name)))
(if (null? record)
(find-employee-record name (cdr branchs))
record))))
d
将新人事的方法注册到表中,即put进去。