我的SICP习题答案(1.40~1.44)

我的SICP习题答案(1.40~1.44)

; ;;;;;;;;;;
;
1.43
(define (double f)
  (lambda(x) (f (f x))))
; ;(((double (double double)) inc) 5) = 5+16 =21

; ;;;;;;;;;;;;
;
1.42
(define (compose f g)
  (lambda(x) (f (g x))))

; ;;;;;;;;;;;;;;
;
1.43
(define (repeated f n)
  (if(
=  n  1 ) f
     (compose f (repeated f (- n 
1 )))))

; ;;;;;;;;;;;;;;;
;
1.44
(define (smooth f)
  (lambda(x) (/ (+ (f (- x dx))
                   (f x)
                   (f (+ x dx)))
                
3 )))
(define (smooth-n f)
  (repeated f n))
(define (smooth-n f n)
  ((repeated smooth n) f))


你可能感兴趣的:(我的SICP习题答案(1.40~1.44))