MathGroup Archive 2007

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

Search the Archive

Re: weird Manipulate/Animate


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