<div dir="ltr">If you were to replace stream-cons with this function:<div><br></div><div>(define (not-stream-cons x y) (printf "x ~s y ~s\n" x y) 'something-random)</div><div><br></div><div>would it make sense to you what happens?</div>
<div><br></div><div>Robby</div></div><div class="gmail_extra"><br><br><div class="gmail_quote">On Thu, May 16, 2013 at 7:30 AM, Patrick Sweetman <span dir="ltr"><<a href="mailto:sweetmanpc@woosh.co.nz" target="_blank">sweetmanpc@woosh.co.nz</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">I'm doing this problem:<br>
<br>
6. Write a stream dan-then-dog, where the elements of the stream<br>
alternate between the strings "dan.jpg" and "dog.jpg" (starting with<br>
"dan.jpg"). More specically, dan-then-dog should be a thunk that when<br>
called produces a pair of "dan.jpg" and a thunk that when called<br>
produces a pair of "dog.jpg" and a thunk that when called... etc. Sample<br>
solution: 4 lines.<br>
<br>
and I cannot for the life of me understand why the following code does<br>
not produce a properly thunked stream. It evaluates the entries until it<br>
runs out of memory<br>
<br>
(define dan "dan.jpg")<br>
(define dog "dog.jpg")<br>
<br>
(define (dan-then-dog)<br>
(define (H1 st0 b0)<br>
(cond<br>
[(= b0 1) (H1 (stream-cons dan st0) 0)]<br>
[else (H1 (stream-cons dog st0) 1)]<br>
)<br>
)<br>
(H1 empty-stream 1))<br>
<br>
Can somebody please explain why my understanding of Racket streams is<br>
faulty?<br>
<br>
Thanks,<br>
Patrick Sweetman<br>
____________________<br>
Racket Users list:<br>
<a href="http://lists.racket-lang.org/users" target="_blank">http://lists.racket-lang.org/users</a><br>
</blockquote></div><br></div>