I'm doing this problem: 6. Write a stream dan-then-dog, where the elements of the stream alternate between the strings "dan.jpg" and "dog.jpg" (starting with "dan.jpg"). More specically, dan-then-dog should be a thunk that when called produces a pair of "dan.jpg" and a thunk that when called produces a pair of "dog.jpg" and a thunk that when called... etc. Sample solution: 4 lines.
and I cannot for the life of me understand why the following code does not produce a properly thunked stream. It evaluates the entries until it runs out of memory (define dan "dan.jpg") (define dog "dog.jpg") (define (dan-then-dog) (define (H1 st0 b0) (cond [(= b0 1) (H1 (stream-cons dan st0) 0)] [else (H1 (stream-cons dog st0) 1)] ) ) (H1 empty-stream 1)) Can somebody please explain why my understanding of Racket streams is faulty? Thanks, Patrick Sweetman ____________________ Racket Users list: http://lists.racket-lang.org/users