need an enhanced (for)
Posted: Sun Apr 12, 2009 9:49 am
G'day everyone
I'm not sure how I'd handle this, as I'm just thinking about it now, but how would one implement a (for) that had two indices rather than the usual one?
For example (pseudopseudocode):
for i = 1 to 10 with j=20 to 2 step -2 do
println i,j
next
The usual thing is to have the for j inside the for i and to get about 100 results. I was thinking more of getting as many results as it takes for either i or j to terminate. That is, if i gets to 10 before j gets to 2 then terminate or vice versa.
I may come up with something soon, but if anyone wants to offer a solution, I'd be very interested.
Kind regards,
Bruce.
I'm not sure how I'd handle this, as I'm just thinking about it now, but how would one implement a (for) that had two indices rather than the usual one?
For example (pseudopseudocode):
for i = 1 to 10 with j=20 to 2 step -2 do
println i,j
next
The usual thing is to have the for j inside the for i and to get about 100 results. I was thinking more of getting as many results as it takes for either i or j to terminate. That is, if i gets to 10 before j gets to 2 then terminate or vice versa.
I may come up with something soon, but if anyone wants to offer a solution, I'd be very interested.
Kind regards,
Bruce.