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))
本文介绍了一种平滑函数的实现方法,并通过定义复合函数和重复应用来达到多次平滑的效果。文中给出了具体的Scheme语言代码示例,包括平滑函数、复合函数定义及平方函数的n次平滑。
2141

被折叠的 条评论
为什么被折叠?



