Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 Multiply Exiting
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
Tallguy




PostPosted: 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.
Sponsor
Sponsor
Sponsor
sponsor
Tony




PostPosted: 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!"
Latest from compsci.ca/blog: Tony's programming blog. DWITE - a programming contest.
darkangel




PostPosted: 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
Nick




PostPosted: Wed Apr 30, 2008 3:37 pm   Post subject: RE:Multiply Exiting

return
darkangel




PostPosted: 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
Display posts from previous:   
   Index -> Programming, Turing -> Turing Help
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 5 Posts ]
Jump to:   


Style:  
Search: