This preview has intentionally blurred sections. Sign up to view the full version.View Full Document
Unformatted text preview: The only thing you can do with the result of (delay . ..) is FORCE it can't ask for its stream-car or stream-cdr, etc. By contrast, with the stream, you can stream-car or stream-cdr it, but *not* force it, because it's not a promise. 4. the 4-2-1 stream. (define (next-num n) (if (even? n) (/ n 2) (+ (* n 3) 1))) (define (num-seq n) (cons-stream n (num-seq (next-num n)))) (define (seq-length s) (if (= (stream-car s) 1) 1 (+ 1 (seq-length (stream-cdr s))))) Sheet1 Page 2 in this case it's (force (delay (+ 1 27))) and that's of you...
View Full Document
This note was uploaded on 09/14/2009 for the course PEIS 100 taught by Professor Mckenzie during the Spring '08 term at Berkeley.
- Spring '08