[plt-scheme] Dead lock using map-stream?

From: Gurpreet S. Saini (gsaini at u.washington.edu)
Date: Sat Nov 22 22:08:51 EST 2003

[Note that both of definitions come from chapter 3 of
the first edition of SICP]

Consider 

1. the following defintions:

(define the-empty-stream '())

(define (enumerate-interval low high)
        (if (> low high)
            the-empty-stream
            (cons-stream low 
                        (enumerate-interval (+ low 1) high))))

(define (map-stream proc stream)
    (if (empty-stream? stream)
         the-empty-stream
         (cons-stream (proc (head stream))
                      (map-stream proc (tail stream)))))

2. And the following call:

(map-stream + (enumerate-interval 0 10))
 
Right now this call is stalled. It looks to me like
this is supposed to happen. This is because both enumerate-interval and 
map-stream's call to tail is in a cons-stream. 


thanks
--Gurp











Posted on the users mailing list.