
-----------------------------------
threatbinder
Sun Dec 20, 2009 8:06 pm

Exit when with 2 for loops
-----------------------------------
for a : 1 .. 3
    for b : 1 .. 3
        put i, b
    end for
end for

Ok so this will obviously output 11 12 13 21 22 23 31 32 33, but I need it to output just 11, 22, 33. How could I use an exit when for it to output what I want?

-----------------------------------
yumrum
Sun Dec 20, 2009 8:15 pm

RE:Exit when with 2 for loops
-----------------------------------
i don't think "exit when" is what u want because the stuff u want to eliminate isn't at the end but thats just me i think u need to make it just not print out the 12,13,21,23,31,32

if there's no limit on code u could do


for a : 1..3
for b : 1..3
if x = 12 or x = 13 or x = 23 or x = 31 or x = 32 then 

else put a,b
end if 
end for 
end for

-----------------------------------
threatbinder
Sun Dec 20, 2009 8:21 pm

Re: RE:Exit when with 2 for loops
-----------------------------------
i don't think "exit when" is what u want because the stuff u want to eliminate isn't at the end but thats just me i think u need to make it just not print out the 12,13,21,23,31,32

if there's no limit on code u could do


for a : 1..3
for b : 1..3
if x = 12 or x = 13 or x = 23 or x = 31 or x = 32 then 

else put a,b
end if 
end for 
end for

how's that possible? you can't have 2 integers with one variable; the only reason 1 and 2 are side by side is because there's no space inbetween the two numbers

if i misunderstood could you please further elaborate?

-----------------------------------
Tony
Sun Dec 20, 2009 8:23 pm

RE:Exit when with 2 for loops
-----------------------------------
That code is obviously not supposed to work, as there is no variable x.

Though it should give you an idea of how to use conditionals to decide if you should or should not print output.

P.S. you can do this with less than 5 comparisons.

-----------------------------------
threatbinder
Sun Dec 20, 2009 8:29 pm

Re: RE:Exit when with 2 for loops
-----------------------------------
That code is obviously not supposed to work, as there is no variable x.

Though it should give you an idea of how to use conditionals to decide if you should or should not print output.

P.S. you can do this with less than 5 comparisons.
edit: nvm i'll just try with conditionals, but is there no way with exit when's?

-----------------------------------
yumrum
Sun Dec 20, 2009 8:30 pm

RE:Exit when with 2 for loops
-----------------------------------
Thanks Tony thats basicly what i meant.. i was just showing u what u should sorta do so u can figure it out a learn..

-----------------------------------
threatbinder
Sun Dec 20, 2009 8:42 pm

Re: RE:Exit when with 2 for loops
-----------------------------------
for a:1..3
for b:1..3
if (a not=1 and b not=2) and (a not=1 and b not=3) and (a not=2 and b not=3) and (a not=3 and b not=1) and (a not=3 and b not=2) then
put a, b
end if
end for
end for

I don't really get it.. how do I use conditionals in this case? because the above I tried and many others don't work. and I really need an efficient way to do this because for my program I'm doing this with 1..16 and 1..16 which is 256 possibilities (and I gotta do that with 4 more (4 quadrants), multiply that by 2 because there's 2 teams which is 2048 >.