[plt-scheme] Re: Lazy streams in SICP

From: Jens Axel Søgaard (jensaxel at soegaard.net)
Date: Thu May 18 12:44:20 EDT 2006

geb a wrote:
> In SICP, lazy streams are formulated as follows...
> 
> (define (cons x y)
>   (lambda (m) (m x y)))
> (define (car z)
>   (z (lambda (p q) p)))
> (define (cdr z)
>   (z (lambda (p q) q)))
> 
> (define ones (cons 1 ones))

That's not what it says:

<http://mitpress.mit.edu/sicp/full-text/book/book-Z-H-24.html#%_idx_3862>

> Running this code in mzscheme yields the following
> error: 
> 
> reference to undefined identifier: ones
> 
> I assume that there is some fundamental difference
> between mzscheme and MIT's version of scheme that
> causes this?  

Nope - you'll get the same result in MIT Scheme.

See

<http://schemecookbook.org/view/Cookbook/MiscSICP>

for a definition of cons-stream.

-- 
Jens Axel Søgaard




Posted on the users mailing list.