[Date Index] [Thread Index] [Author Index]
Re: Why Return does not work?
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