Computer Science Canada

Multiply Exiting

Author:  Tallguy [ Wed Apr 30, 2008 8:30 am ]
Post subject:  Multiply Exiting

How does one exit out of multiply loops (nested loops)once a statement is true.

Author:  Tony [ Wed Apr 30, 2008 9:31 am ]
Post subject:  RE:Multiply Exiting

you can place the entire structure into a function and return out of that, or use multiple exit when statements
Turing:

loop
   put "start outter loop"
   loop
      put "start inner loop"
      exit when true
      put "inner loop skipped"
   end loop
   exit when true
   put "outer loop skipped"
end loop
put "done!"

Author:  darkangel [ Wed Apr 30, 2008 3:33 pm ]
Post subject:  Re: Multiply Exiting

Tony wrote:

you can place the entire structure into a function and return out of that, or use multiple exit when statements
Turing:

loop
   put "start outter loop"
   loop
      put "start inner loop"
      exit when true
      put "inner loop skipped"
   end loop
   exit when true
   put "outer loop skipped"
end loop
put "done!"


Is there any other way thats more efficient? When you have 3 or 4 procedures and most have nested loops it can get crowded very quickly with all the "exit when"'s

Author:  Nick [ Wed Apr 30, 2008 3:37 pm ]
Post subject:  RE:Multiply Exiting

return

Author:  darkangel [ Wed Apr 30, 2008 4:02 pm ]
Post subject:  Re: RE:Multiply Exiting

nick @ Wed Apr 30, 2008 3:37 pm wrote:
return

Its sad that i forgot this even thou i posted this exact syntax not 15 minutes ago


: