Funny, I was trying the same Homework, implemented interleaveStreams using
the same algorithm you did (taking one item from each stream per recursive
call), and got the same result with the ruler function hanging. It was also
fixed by changing interleaveStreams to take from just one stream per call
and switch back and forth between streams.
This happened even though I implemented my ruler function itself
recursively:
ruler' :: Integer -> Stream Integer
ruler' n = interleaveStreams (streamRepeat n) (ruler' (n + 1))
ruler = ruler' 0
Sorry, but I also don't know why. I speculate that if one were to expand it
out on pencil and paper, they'd find that the interleaved stream somehow
expands at a different rate than the ruler (half or twice).
-Curt
_______________________________________________
Beginners mailing list
Beginners@haskell.org
http://www.haskell.org/mailman/listinfo/beginners