zoukankan      html  css  js  c++  java
  • 【SICP练习】133 练习3.64

    练习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)))



    感谢访问,希望对您有所帮助。 欢迎关注或收藏、评论或点赞。


    为使本文得到斧正和提问,转载请注明出处:
    http://blog.csdn.net/nomasp


    版权声明:本文为 NoMasp柯于旺 原创文章,如需转载请联系本人。

  • 相关阅读:
    BugReport-仿微信app
    成长、责任、和公司的关系
    团队如何做决定
    课堂练习
    课堂练习
    NABCD model
    课堂练习
    日程管理测试用例
    测试
    Bug报告
  • 原文地址:https://www.cnblogs.com/NoMasp/p/4786067.html
Copyright © 2011-2022 走看看