Services & Resources / Wolfram Forums / MathGroup Archive

MathGroup Archive 2010

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

Search the Archive

Re: Table local

  • To: mathgroup at
  • Subject: [mg113809] Re: Table local
  • From: Bob Hanlon <hanlonr at>
  • Date: Sun, 14 Nov 2010 06:07:43 -0500 (EST)

"Table[expr, spec] first evaluates spec, then localizes the variable specified, and successively assigns values to it, each time evaluating expr."

In other words, what is localized is the index i

Clear[i, u];
Table[u = i^2, {i, 5}];
{i, u}

{i, 25}

Clear[i, u];
u = 0; Table[u += i^2, {i, 5}];
{i, u}
u == Sum[i^2, {i, 5}]

{i, 55}


Bob Hanlon

---- EF <he.frauendorfer at> wrote: 

"Help, More Information" for Table states:

  Table effectively uses Block to localize values or variables.

   Table[u = i^2, {i, 5}];

   Table[u = i^2;, {i, 5}];

   In both cases the value 25 for u is given.
   If u were really local, it should have no value outside of the Table

   For me there is a contradiction that can cause a lot of trouble

   E. F.

  • Prev by Date: Re: Table local
  • Next by Date: Re: Sort a List, in a List of Lists of Lists
  • Previous by thread: Re: Table local
  • Next by thread: Sort a List, in a List of Lists of Lists