Tuesday, September 30, 2008

sicp-exercise-1.44-1.46

Exercise 1.43


(define (average a b c) ;there should be a general way to get average
  (/ (+ a b c) 3.0))

(define (smooth f)
  (lambda (x)
    (average (f x)
             (f (- x 0.5))
             (f (+ x 0.5)))))

(define (n-fold-smooth f n)
    (repeated (smooth f) n))
I need to check my answer through some examples, will find some later.

0 comments:

Post a Comment