首页 > 其他 > 详细

【SICP练习】133 练习3.64

时间:2015-03-29 09:28:48      阅读:249      评论:0      收藏:0      [点我收藏+]

练习3-64

原文

Exercise 3.64. Write a procedure stream-limit that takes as arguments a stream and a number (the tolerance). It should examine the stream until it finds two successive elements that differ in absolute value by less than the tolerance, and return the second of the two elements. Using this, we could compute square roots up to a given tolerance by

(define (sqrt x tolerance)  (stream-limit (sqrt-stream x) tolerance))

代码

(define (stream-limit stream tolerance)
        (if (< (abs (- (stream-ref stream 1) (stream-ref stream 0))) tolerance)
                (stream-ref stream 1)
                (stream-limit (stream-cdr stream) tolerance)))

【SICP练习】133 练习3.64

原文:http://blog.csdn.net/nomasp/article/details/44710395

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!