<< Previous exercise (3.50) | Index | Next exercise (3.52) >>

perry

(define (show x) (display-line x) x) (define x (stream-map show (stream-enumerate-interval 0 10))) 0 ;Value: x (stream-ref x 5) 1 2 3 4 5 ;Value: 5 (stream-ref x 7) 6 7 ;Value: 7

master

I get a different result. On Racket, with all of the procedures implemented exactly as specified in the book, I get:

racket@> (define x (stream-map show (stream-enumerate-interval 0 10))) 0 1 2 3 4 5 6 7 8 9 10racket@> (stream-ref x 5) 5 racket@> (stream-ref x 7) 7

The only thing which could possibly account for this discrepancy is a mistake in my implementation of delay, but it looks fine to me?

(define delay (lambda (proc) (memo-proc (lambda () proc))))

Any idea why I get different results?

EDIT: After solving the next exercise and looking at other solutions, it seems like the evaluations aren't actually being delayed, could it be some aspect of Racket's implementation which is preventing it from working?

master

I get a different result. On Racket, with all of the procedures implemented exactly as specified in the book, I get:

The only thing which could possibly account for this discrepancy is a mistake in my implementation of

delay, but it looks fine to me?`(define delay (lambda (proc) (memo-proc (lambda () proc))))`

Any idea why I get different results?

EDIT: After solving the next exercise and looking at other solutions, it seems like the evaluations aren't actually being delayed, could it be some aspect of Racket's implementation which is preventing it from working?