Services & Resources / Wolfram Forums / MathGroup Archive
-----

MathGroup Archive 2010

[Date Index] [Thread Index] [Author Index]

Search the Archive

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: <hr6ihp$2f8$1@smc.vnet.net> <hr6la2$5im$1@smc.vnet.net> <hr8io7$507$1@smc.vnet.net>

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


  • Prev by Date: Odd phenomenon
  • Next by Date: Re: NDSolve: ..numerically ill-conditioned...
  • Previous by thread: Re: Why Return[] does not work?
  • Next by thread: Re: Why Return[] does not work?