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
  • Subject: [mg109487] Re: Why Return[] does not work?
  • From: David Bailey <dave at>
  • Date: Thu, 29 Apr 2010 02:54:11 -0400 (EDT)
  • References: <hr6ihp$2f8$> <hr6la2$5im$> <hr8io7$507$>

Dims wrote:
> On 27 =D0=B0=D0=BF=D1=80, 16:28, Albert Retey <a... at> 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:

do something;

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

  • 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?