<div dir="ltr"><div class="gmail_default" style="font-family:courier new,monospace">Having a little problem getting something working with sequences.<br><br>What I'd like to do is have two sequences, call them seq-a and seq-b, which are appended to each other like (in-sequences ...), except that when seq-a runs out it passes information to seq-b in order for seq-b to know how to start. <br>
<br>I thought that I could be sneaky and have the procedure returned by sequence-generate* return a value even though the sequence had ostensibly ended, but the docs aren't lying: it's an error to evaluate that procedure after the sequence has ended. <br>
<br>Next I tried making the main sequence struct a subtype of another struct. But this fails in surprising ways. Simple example to show the problem:<br>;;;;;;;;;;;;<br>(struct addable (x))<br><br>(struct adder addable (y)<br>
#:property prop:sequence<br> (λ(p)<br> (make-do-sequence<br> (λ()<br> (values (λ(pos) (adder-y pos))<br> (λ(pos) <br> (adder (+ (adder-y pos) (adder-x pos))<br>
(adder-x pos)))<br> p<br> #f #f #f)))))<br>;;;;;;;;;;;;<br>adder-x: unbound identifier in module in: adder-x<br><br>Unexpected. I thought this could be fixed by replacing <br>
(adder-x pos) <br>with <br>(addable-x pos) since this works:<br><br>> (struct posn (x y))<br>> (struct 3d posn (z))<br>> (posn-x (3d 'x 'y 'z))<br>'x<br><br>This gives no errors but it breaks in unexpected ways.<br>
;;;;<br>> (struct addable (x)) <br>> (struct adder addable (y)<br> #:property prop:sequence<br> (λ(p)<br> (make-do-sequence<br> (λ()<br> (values <br> (λ(pos) (adder-y pos))<br> (λ(pos) <br>
(adder (+ (adder-y pos) <br> (addable-x pos)) <br><div class="gmail_default"> (addable-x pos)))<br> p<br> #f #f #f))))) <br>
> (for ((t (adder 0 2))<br> (i (in-range 10)))<br> (printf "~a " t))<br>2 0 2 2 4 6 10 16 26 42 </div><br>So there seems to be no hope that way.<br><br>Any chance there is a way to pass information between two subsequences so that the overall iteration doesn't notice anything happening behind the scenes? Is mutation the only hope?<br>
<br>Deren<br></div></div>