Services & Resources / Wolfram Forums
-----
 /
MathGroup Archive
2007
*January
*February
*March
*April
*May
*June
*July
*August
*September
*October
*Archive Index
*Ask about this page
*Print this page
*Give us feedback
*Sign up for the Wolfram Insider

MathGroup Archive 2007

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

Search the Archive

Re: weird Manipulate/Animate

  • To: mathgroup at smc.vnet.net
  • Subject: [mg76693] Re: [mg76682] weird Manipulate/Animate
  • From: "Lev Bishop" <lev.bishop at gmail.com>
  • Date: Sat, 26 May 2007 04:22:31 -0400 (EDT)
  • References: <200705251050.GAA08454@smc.vnet.net>

On 5/25/07, mire <virgiliub at yahoo.com> wrote:
> does anyone know why this code works
>
> graph = Table[Plot[Sin[x + i], {x, 0, \[Pi]}], {i, 3}];
> ListAnimate[graph]
>
> and this one doesn't
>
> n = 3; graph = Table[0, {n}];
> For[i = 1, i <= n, i++,
>   graph[[i]] = Show[Plot[Sin[x + i], {x, 0, \[Pi]}]]];
> ListAnimate[Evaluate[graph]]

Heh. Because even WRI can't remember mathematica's bizarre and
confusing scoping rules?
A more succinct example of the problem:
i=1;
ListAnimate[{"a","b","c"}]

Ie, the problem is that ListAnimate gets tripped up by Global`i.
Somewhere in the definition of ListAnimate is this:
Manipulate`Dump`res=With[{Manipulate`Dump`i=Symbol[i],....] ,
which almost makes it look as though this is on purpose, but I can't see why.

Anyway, for now, just don't use the variable i in any situation where
you might use ListAnimate.

Lev


  • Prev by Date: Re: .m packages "fullforms" subscripts?
  • Next by Date: Re: Running math in shell with notebook as output
  • Previous by thread: weird Manipulate/Animate
  • Next by thread: packages question