Blame


1 665c255d 2023-08-04 jrmu
2 665c255d 2023-08-04 jrmu Exercise 3.52. Consider the sequence of expressions
3 665c255d 2023-08-04 jrmu
4 665c255d 2023-08-04 jrmu (define sum 0)
5 665c255d 2023-08-04 jrmu (define (accum x)
6 665c255d 2023-08-04 jrmu (set! sum (+ x sum))
7 665c255d 2023-08-04 jrmu sum)
8 665c255d 2023-08-04 jrmu (define seq (stream-map accum (stream-enumerate-interval 1 20)))
9 665c255d 2023-08-04 jrmu (define y (stream-filter even? seq))
10 665c255d 2023-08-04 jrmu (define z (stream-filter (lambda (x) (= (remainder x 5) 0))
11 665c255d 2023-08-04 jrmu seq))
12 665c255d 2023-08-04 jrmu (stream-ref y 7)
13 665c255d 2023-08-04 jrmu (display-stream z)
14 665c255d 2023-08-04 jrmu
15 665c255d 2023-08-04 jrmu 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 <exp>) simply as (lambda () <exp>) without using the optimization provided by memo-proc ? Explain.