Re: Why Return does not work?
- To: mathgroup at smc.vnet.net
- Subject: [mg109487] Re: Why Return does not work?
- From: David Bailey <dave at removedbailey.co.uk>
- Date: Thu, 29 Apr 2010 02:54:11 -0400 (EDT)
- References: <firstname.lastname@example.org> <email@example.com> <firstname.lastname@example.org>
Dims wrote: > On 27 =D0=B0=D0=BF=D1=80, 16:28, Albert Retey <a... at gmx-topmail.de> wrote: >> Am 27.04.2010 13:41, schrieb Dims: >> Intersects[x_List, y_List] := Catch[ > > Yes, thank you, I also came to conclusion, that catch works. But I > think it is a bug with return, since manual says, that we CAN use > Return inside Do. > Yes, but it will exit one Do construct, and you have two! Everyone needs to use explicit loops sometimes (or at least I do!) but I find While loops are more convenient: j=1; While[j<=10, do something; j++ ]; One reason is that yo can set a boolean, and add it to the test on the While - thus exiting as many loops as needed. I take it you realise that there is a built in function Intersect, and that this was a programming exercise. David Bailey http://www.dbaileyconsultancy.co.uk