您的位置:首页 > 其它

SICP 习题1.44 smooth

2016-06-05 00:10 190 查看

smooth函数

(define (smooth f)
(lambda (x)
(/ (+ (f (- x dx)) (f x) (f (+ x dx))) 3)))

(define dx 0.001)

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

(define (repeated f times)
(if (= times 1)
f
(compose f (repeated f (- times 1)))))

(define (n-smooth f n)
(lambda (x)
(((repeated smooth n) f) x)))

(define square
(lambda (x) (* x x)))

(newline)
(display ((n-smooth square 10) 5))
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: