SICP 习题1.44 smooth

来源:互联网 发布:整合pdf的软件 编辑:程序博客网 时间:2024/06/15 01:48

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))
0 0
原创粉丝点击