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: [mg109461] Re: Why Return[] does not work?
  • From: DrMajorBob <btreat1 at austin.rr.com>
  • Date: Wed, 28 Apr 2010 01:59:12 -0400 (EDT)

IMHO, Return doesn't work because it's a bad idea. Don't use it.

Bobby

On Tue, 27 Apr 2010 06:41:50 -0500, Dims <dims12 at hotmail.com> wrote:

> I wrote a function to check if two lists contain equal members:
>
> Intersects[x_List,
>   y_List] := (Do[(Print["Outer step ", xi];
>     Do[(Print[xi, yi];
>       If[xi == yi, (Print["Returning True"]; Return[True])]), {yi,
>       y}]), {xi, x}]; False)
>
> But it returns False for interecting lists:
>
> In[47]:= Intersects[{a, b}, {c, a}]
> During evaluation of In[47]:= Outer step a
> During evaluation of In[47]:= ac
> During evaluation of In[47]:= aa
> During evaluation of In[47]:= Returning True
> During evaluation of In[47]:= Outer step b
> During evaluation of In[47]:= bc
> During evaluation of In[47]:= ba
> Out[47]= False
>
> Few questions:
>
> 1) why does not Return[] interrupt the loops?
> 2) is there better way to implement intersection check?
>
> Thanks
>


-- 
DrMajorBob at yahoo.com


  • Prev by Date: How to disable Integrate[] ?
  • Next by Date: Re: Database memory usage
  • Previous by thread: Re: Why Return[] does not work?
  • Next by thread: Re: Why Return[] does not work?