<div>I wrote SRFI-40, and am currently working on SRFI-41. No promises when it will be ready, though. It will require the module system of R6RS (also records, error, and case-lambda). If you're interested in code, I could send you some. The current version of the code has stream comprehensions and also pattern-matching on streams. It also has bugs. Someone earlier in the thread said that SRFI-40 is tricky, and doesn't always delay what they expected; yes, that happens to me, too.
<div><span class="gmail_quote">On 8/3/07, <b class="gmail_sendername">David Einstein</b> <<a href="mailto:email@example.com">firstname.lastname@example.org</a>> wrote:</span>
<blockquote class="gmail_quote" style="PADDING-LEFT: 1ex; MARGIN: 0px 0px 0px 0.8ex; BORDER-LEFT: #ccc 1px solid">I do not know if you know, but there are a lot of stream utilities in<br>the initial proposal of srfi-40, that were going to be moved to
<br>srfi-41, but I assume that the author lost interest before that<br>happened.<br><br>On 8/3/07, Mark Engelberg <<a href="mailto:email@example.com">firstname.lastname@example.org</a>> wrote:<br>> On 8/3/07, Matthias Felleisen <
<a href="mailto:email@example.com">firstname.lastname@example.org</a>> wrote:<br>> > Mark, why don't you try two different things:<br>> ><br>> > 1. use the srfis for lazy streams and comprehension to rewrite the
<br>> > solutions<br>> ><br>> > 2. use Lazy Scheme and hack together a comprehension macro.<br>> ><br>><br>> Actually, I ended up getting satisfactory results by tweaking misc.ss<br>> from the swindle directory. I chose to do this because I find
<br>> swindle's comprehension syntax to be more comfortable than the srfi<br>> version (probably because of its similarity to math/Haskell).<br>><br>> Here are the changes I made:<br>><br>> ;;added for stream support
<br>> (require (lib "40.ss" "srfi"))<br>><br>> ;;added stream comprehension<br>> (defsubst* (stream-of expr clause ...)<br>> (collect => (_ stream-null (stream-cons expr _)) clause ...))
<br>><br>> ;;added stream case to collect-iterator so streams can be used in generators<br>> (define* (collect-iterator seq)<br>> (define (out-of-range r) (lambda (x) (<= r x)))<br>> (cond<br>> [(list? seq) (list seq cdr null? car)]
<br>> ;;> * stream: iterate over the stream's element;<br>> ;;> This is the new line I added. Everything else is the same.<br>> [(stream? seq) (list seq stream-cdr stream-null? stream-car)]<br>> [(vector? seq) (list 0 add1 (out-of-range (vector-length seq))
<br>> (lambda (i) (vector-ref seq i)))]<br>> [(string? seq) (list 0 add1 (out-of-range (string-length seq))<br>> (lambda (i) (string-ref seq i)))]<br>> [(integer? seq) (list 0 add1 (out-of-range seq) #f)]
<br>> [(procedure? seq)<br>> (function->iterator seq)]<br>> [(hash-table? seq)<br>> (collect-iterator (lambda (yield)<br>> (hash-table-for-each<br>> seq (lambda (k v) (yield (cons k v))))))]
<br>> [else (list seq identity #f #f)]))<br>><br>> I'm pretty happy with this. The stream srfi library is pretty<br>> minimalist, of course. I had to add a lot of useful functions like<br>> stream-takewhile and more.
<br>><br>> So yes, it's cool that Scheme (and in particular, Eli's code) can be<br>> easily extended in this way. I would have been even happier if I<br>> didn't need to do it myself :) .<br>><br>
> --Mark<br>><br>_________________________________________________<br>For list-related administrative tasks:<br><a href="http://list.cs.brown.edu/mailman/listinfo/plt-scheme">http://list.cs.brown.edu/mailman/listinfo/plt-scheme