标签:local arguments stream limit examine
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)))
标签:local arguments stream limit examine
原文地址:http://blog.csdn.net/nomasp/article/details/44710395