I defined the Scheme procedure to return another procedure with 2 parameters :
(define (smooth f)
(λ(x dx)(/ (+ (f (- x dx))
(f x)
(f (+ x dx)))
3.0)))
if i run this procedure with sin procedure with 2 arguments 10 and 0.0001 then it is ok
((smooth sin) 10 0.0001) ==> -0.544021109075966
if i run this procedure recursively, then it has error
((smooth (smooth sin)) 10 0.0001)
==> procedure expects 2 arguments, given 1: #<promise:temp6>
So can anyone tell me where is my problem?
Thank you in advance !!!
PS:this is apart of exercise 1.44 in SICP
It’s pretty simple, the result of
(smooth sin)is a 2-argument procedure which becomes the F in the outer SMOOTH, and F is applied to only one value.The solution is to make the result of SMOOTH a 1-argument procedure instead, then you can apply it repeatedly.