|
[Date Index]
[Thread Index]
[Author Index]
Re: Strange behaviour of Do in Compile
- To: mathgroup at smc.vnet.net
- Subject: [mg82201] Re: [mg82125] Strange behaviour of Do in Compile
- From: DrMajorBob <drmajorbob at bigfoot.com>
- Date: Sun, 14 Oct 2007 06:19:39 -0400 (EDT)
- References: <22686441.1192263837882.JavaMail.root@m35>
- Reply-to: drmajorbob at bigfoot.com
Better yet, never use Return at all. I never do.
Bobby
On Sat, 13 Oct 2007 02:41:37 -0500, Andrew Moylan
<andrew.j.moylan at gmail.com> wrote:
> Compile[{}, Do[If[i > 10, Return[i + 1]], {i, 10}]][]
>
> On my machine, this returns such values as:
> 176792864
> 176795048
> 176797232
>
> The following slight modification always returns the value 11:
>
> Compile[{}, Do[If[i > 10, Return[i]], {i, 10}]][]
>
> Can anyone explain this behaviour?
>
> Anyway, I guess the moral is: always explicitly return a value from
> Compile,
> and don't rely on the usual return value properties of flow-control
> constructs like Do.
>
>
>
--
DrMajorBob at bigfoot.com
Prev by Date:
Re: Locator in Manipulate's graphic.
Next by Date:
Re: rule based program for "Deleting repeated members of a list."
Previous by thread:
Strange behaviour of Do in Compile
Next by thread:
Re: Re: [Mathematica 6] Format->Magnification does not
|