[plt-scheme] Stream comprehensions
So a few months ago, my son started working on the Project Euler
problems in Scheme. After solving a few of the problems, he
particularly enjoyed going through the forums, asking me to explain to
him the solutions in the other programming languages. He was struck
by the brevity of the Haskell solutions, and begged me to teach him
some Haskell.
So for the past couple of months, he's been working the problems in Haskell.
Now, I'm trying to move him back to Scheme to continue Htdp; problem
is, he's been spoiled by some of the niceties of Haskell. In
particular, the ease of working with large or possibly infinite lists
lazily, and using comprehensions to express complex cartesian
products, maps and filters elegantly.
Swindle's comprehension syntax is extremely close to Haskell's, so
this is a pretty easy switch.
For lazy lists, there are a few possibilities.
1. Use the streams in srfi40.
2. Show him how to implement streams himself using force/delay.
3. Switch to Lazy Scheme language level and use regular lists.
The problem is that none of these options seem to interact well with
comprehensions.
So... does anyone know of a comprehension macro system for DrScheme
that interacts seamlessly with streams? Should I roll my own using
the collect macro in swindle, or has this already been done?
Thanks,
Mark