Re: First question
- To: mathgroup at smc.vnet.net
- Subject: [mg52124] Re: First question
- From: Peter Pein <petsie at arcor.de>
- Date: Thu, 11 Nov 2004 04:52:49 -0500 (EST)
- References: <cmsp1e$bah$1@smc.vnet.net>
- Sender: owner-wri-mathgroup at wolfram.com
dto_mba at skynet.be wrote:
> How to exit directly and immediately a module from inside a loop with
> a certain value ?
> Return seems not to work.
>
> Example:
>
> lmaa := Module[
> {},
> Do[
> If[i > 3, Return[{"from inside"}]],
> {i, 1, 5}
> ];
> Return[{"not from inside"}]
> ]
>
>
> lmaa
>
> {not from inside}
>
> Best
>
> Gilbert Gosseyn
>
Read in the docs about Catch[] and Throw[]:
lmaa := Module[{},
Do[If[i > 3, Throw[{"from inside"}]],
{i, 1, 5}];
{"not from inside"}]
Catch[lmaa]
{"from inside"}
--
Peter Pein
Berlin