MathGroup Archive 2004

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

Search the Archive

Re: First question

  • To: mathgroup at smc.vnet.net
  • Subject: [mg52132] Re: [mg52091] First question
  • From: Andrzej Kozlowski <andrzej at akikoz.net>
  • Date: Thu, 11 Nov 2004 04:53:23 -0500 (EST)
  • Sender: owner-wri-mathgroup at wolfram.com

Actually, I was again not paying attention; you do not need either 
Return or Throw or anything in the second Return position:

lmaa := Module[
{},
   Catch[ Do[
      If[i > 3, Throw[{"from inside"}]],
      {i, 1, 5}
    ];
  "not from inside"]
]

is all you need in this kind of code. You do not need Return or 
anything else to return output in Mathematica, only to exit certain 
loops.


Andrzej Kozlowski


On 11 Nov 2004, at 06:55, Andrzej Kozlowski wrote:

> I just copied your post and forgot to change the second Return also to 
> Throw.
>
> Andrzej
>
>
> On 11 Nov 2004, at 04:36, dto_mba at skynet.be wrote:
>
>> *This message was transferred with a trial version of CommuniGate(tm) 
>> Pro*
>> Throw ? Catch ? , are we talking about Baseball ? :-)
>>
>> Why does the Catch include 'Return[{"not from inside"}]' ?
>>
>> Best,
>>
>> GG
>>
>>
>> -- snip
>>
>>
>>>
>>> Method 2 (recommended):
>>>
>>>
>>> lmaa := Module[
>>> {},
>>>   Catch[ Do[
>>>      If[i > 3, Throw[{"from inside"}]],
>>>      {i, 1, 5}
>>>    ];
>>>    Return[{"not from inside"}]]
>>> ]
>>>
>>>
>>>
>>> lmaa
>>>
>>>
>>> {from inside}
>>>
>>>
>>> Finally, there is absolutely no point using a Module whiteout any 
>>> local variables.
>>>
>>>
>>>
>>> Andrzej Kozlowski
>>> Chiba, Japan
>>> http://www.akikoz.net/~andrzej/
>>> http://www.mimuw.edu.pl/~akoz/
>>
>


  • Prev by Date: equal distribution of last digits base ten in the primes by b-normality
  • Next by Date: Re: nonlinear programming with differential-algebraic constraints (2)
  • Previous by thread: Re: First question
  • Next by thread: Two y-axes in one graph