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: [mg109496] Re: Why Return[] does not work?
  • From: Andrzej Kozlowski <akoz at mimuw.edu.pl>
  • Date: Fri, 30 Apr 2010 05:49:54 -0400 (EDT)
  • References: <hr6ihp$2f8$1@smc.vnet.net> <hr6la2$5im$1@smc.vnet.net> <201004280558.BAA05169@smc.vnet.net>

I am not sure if anyone pointed out that if enough Returns are used the original code will work as expected:

Intersects[x_List, y_List] := (Do[(Print["Outer step ", xi];
    Do[(Print[xi, yi];
      If[xi == yi, (Print["Returning True"];
        Return[Return[Return[True]]])]), {yi, y}]), {xi, x}]; False)

In[2]:= Intersects[{a,b},{c,a}]
During evaluation of In[2]:= Outer step a
During evaluation of In[2]:= ac
During evaluation of In[2]:= aa
During evaluation of In[2]:= Returning True
Out[2]= True

On 28 Apr 2010, at 14:58, 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[].
>



  • Prev by Date: Series acting on a symbolic function
  • Next by Date: Re: How to disable Integrate[] ?
  • Previous by thread: Re: Why Return[] does not work?
  • Next by thread: Re: Why Return[] does not work?