Streams: Conceptual Solutions
what would scheme display?
>>> (define (f x) (+ x 6))
f
>>> (define str (cons-stream (f 1) (cons-stream (f 2) str)))
str
>>> (car str)
7
>>> (cdr str)
#[promise (not forced)]
>>> (cdr-stream str)
(8 . #[promise (not forced)])
>>> (cdr str)
#[promise (forced)]
>>> (define (f x) (+ x 8))
f
>>> (cdr-stream str)
(8 . #[promise (not forced)])
>>> (cdr-stream (cdr-stream str))
(9 . #[promise (not forced)])
>>> (define (f x) (- x 1))
f
>>> (cdr-stream (cdr-stream (cdr-stream str)))
(1 . #[promise (not forced)])