zoukankan      html  css  js  c++  java
  • 【SICP练习】127 练习3.58

    练习3-58

    原文

    Exercise 3.58. Give an interpretation of the stream computed by the following procedure:

    (define (expand num den radix)  
        (cons-stream 
          (quotient (* num radix) den)  
          (expand (remainder (* num radix) den) den radix)))

    (Quotient is a primitive that returns the integer quotient of two integers.) What are the successive elements produced by (expand 1 7 10) ? What is produced by (expand 3 8 10) ?

    分析

    (expand 1 7 10)
    => (quotient (* 1 10) 7)
    => 1
    => (expand (remainder 10 7) 7 10)
    => (quotient (* 3 10) 7)
    => 4
    => (expand (remainder 30 7) 7 10)
    => (quotient (* 2 10) 7)
    => 2
    ……
    ……
    => 1 4 2 8 5 7 4 2 8 5 7 ...
    
    
    (expand 3 8 10)
    ……
    ……
    => 3 7 5 0 0 0 ...



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


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


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

  • 相关阅读:
    前端JS 4
    前端JS 3
    前端JS 2
    前端JS 1
    JS的知识补丁
    去除inline-block元素间的空隙
    js中“||”和“&&”的高级用法
    WebAPP-1
    Node.js_1
    click和onclick的区别
  • 原文地址:https://www.cnblogs.com/NoMasp/p/4786073.html
Copyright © 2011-2022 走看看