[plt-scheme] Dead lock using map-stream?
On Sunday, November 23, 2003, at 01:32 PM, G. Saini wrote:
> For list-related administrative tasks:
> http://list.cs.brown.edu/mailman/listinfo/plt-scheme
>
> Oops, you're right this makes no sense. The plus operator, of course,
> requires at least two operands. Hence I tried the incrementor operator
> (1+). So instead of +, we use 1+:
>
> (map-stream 1+ (enumerate-interval 0 10))
>
> The result still seems to be stalled. It is:
> ;Value 34: (1.#[promise])
>
> My suspicion, after a good night's rest of course, is that this is the
> way it is supposed to be since no tail has been evaluated yet. Hence
> I wrote a simple printout procedure to force the evaluation:
>
> (define (show-all stream)
> (if (empty-stream? stream)
> the-empty-stream
> (begin (format #t " \n ~A \n" (head stream))
> (show-all (tail stream)))))
>
> Now the following call will print out the incremented list properly:
>
> (show-all (map-stream 1+ (enumerate-interval 0 10)))
>
> I conclude then that the novice lesson for me is that the full
> will ONLY be evaluated when there is an explict call to tail
> without being in a cons-stream.
Your suspicion is of course correct. A lazy program is lazy.
It does nothing ... until you demand some information from it.
-- Matthias