<br><br><div><span class="gmail_quote">On 9/20/07, <b class="gmail_sendername">Jens Axel Søgaard</b> <<a href="mailto:jensaxel@soegaard.net" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)">jensaxel@soegaard.net
</a>> wrote:</span><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
David Einstein wrote:<br>> I am glad to see that plt is considering including some comprehension<br>> macros. I realize that they are not yet final, but I have some comments.<br>><br>> A) The behavior of in-range seems to have been inherited from srfi-42
<br>> and python. In my opinion it is one of the few things that python gets<br>> wrong. If you assign problems 7 through 9 as homework to your students,<br>> do you really expect them to hand back just problems 7 and 8? (These
<br>> would be abstract ideal students.)<br><br>ad A)<br><br>Given a vector (or string or byte-string) v it common to iterate through<br>the indices 0, 1, ... (- (vector-length v) 1). Convenience of the<br>common case therefore dictates the last index in the range to be
<br>excluded.</blockquote><div><br>Yes, but in this case you would just use the appropriate string or byte-string sequence. The purpose of comprehensions is to get away from indexing. <br></div><br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
> D) A 'for*/seq' form that takes a set of nested sequences and<br> > returns a generator for all the values of the nested would be useful.<br> > I've been trying to get one integrated into Jens' srfi-42 rewrite
<br> > using William Farr's multiple value yield, but my macro skills are not<br> > yet up to the task.<br><br>ad D)<br><br>Do you have an example of the intended behaviour?</blockquote><div><br> In terms of srfi-42 something the ability to do something like
<br><br>(list-ec (:while [:nested (:range a 2 10) (:range b 1 a) (if (= 1 (gcd a b)))] (< 7 (+ a b)) [list a b])<br><br>in terms of for.ss, something like<br><br>(for (stop-after [(a b) (for*/seq ((a1 [in-range 2 10])(b1 [in-range 1 a1]) #:when (= 1 [gcd a1 b1])) (yield a1 b1)] (< 7 (+ a b))) (list a b))
<br><br>these should result in<br><br>'((2 1) (3 1) (3 2) (4 1))<br><br>essentially what I want is functionality similar to Java's labeled breaks. Not something that you need often (unless you're doing Project Euler problems), but when you need them, they are indispensable. I don't see any real need to be able to run nested loops in parallel, but I don't see any reason that running them in parallel should be disallowed.
<br><br>I'm not sure of the syntax of for*/seq. playing with :nested in srfi-42, I just returned everything declared, but I can see that it might be useful to be able to specify some subset (It makes the macrology easier as well, as the macro does not need to collect the variable names)
<br><br><br><br></div><br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
--<br>Jens Axel Søgaard<br><br></blockquote></div><br>