zoukankan      html  css  js  c++  java
  • 【SICP练习】121 练习3.52

    练习3-52

    原文

    Exercise 3.52. Consider the sequence of expressions

    (define sum 0) 
    
    (define (accum x)
       (set! sum (+ x sum)) 
       sum) 
    
    (define seq (stream-map accum (stream-enumerate-interval 1 20)))
    (define y (stream-filter even? seq)) 
    (define z (stream-filter (lambda (x) (= (remainder x 5) 0))                         seq)) 
    
    (stream-ref y 7) 
    (display-stream z)

    What is the value of sum after each of the above expressions is evaluated? What is the printed response to evaluating the stream-ref and display-stream expressions? Would these responses differ if we had implemented (delay ) simply as (lambda () ) without using the optimization provided by memo-proc ? Explain.

    代码

    (define seq (stream-map accum (stream-enumerate-interval 1 20)))
    
    sum
    
    ;Value: 1
    
    (define y (stream-filter even? seq))
    
    sum
    
    ;Value: 6
    
    (define z (stream-filter (lambda (x) (= (remainder x 5) 0)) seq))
    
    (stream-ref y 7)
    
    ;Value: 136
    



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


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


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

  • 相关阅读:
    c# mvc action 跳转方式
    where T : new() 的含义
    HTML5 Dataset data-属性
    EF6 教程
    C写的AES(ECB/PKCS5Padding)
    【转载】openwrt: Makefile 框架分析
    SCP 命令【转】
    HTTP协议详解(转载)
    bootstrap模板
    拖拽插件
  • 原文地址:https://www.cnblogs.com/NoMasp/p/4786079.html
Copyright © 2011-2022 走看看