Chapter 1, Building Abstractions with Procedures
Section - Formulating Abstractions with Higher-Order Procedures
Exercise 1.44
Here goes our smoothing function:
1
2
3
4
5
6
(define (smooth f)
(define (average a b c)
(/ (+ a b c) 2)
)
(lambda (x) (average (f (- x dx)) (f x) (f (+ x dx)) ))
)
Procedure for nth-smoothing:
1
2
3
(define (nth-smooth f n)
((repeated smooth n) f)
)
Note that it we may also think of doing nth-smoothing instead in the following way:
1
2
3
(define (smooth-nth f n)
(repeated (smooth f) n)
)
I think it is not correct as this is repeating (smooth f)
n times. As to quote from the exercise:
It is sometimes valuable to repeatedly smooth a function (that is, smooth the smoothed function, and so on) to obtained the n-fold smoothed function.
We need to do smoothing of the smoothed function n times.