Services & Resources / Wolfram Forums
MathGroup Archive
*Archive Index
*Ask about this page
*Print this page
*Give us feedback
*Sign up for the Wolfram Insider

MathGroup Archive 2002

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

Search the Archive

RE: Iterators

  • To: mathgroup at
  • Subject: [mg32859] RE: [mg32826] Iterators
  • From: "Wolf, Hartmut" <Hartmut.Wolf at>
  • Date: Sat, 16 Feb 2002 04:35:15 -0500 (EST)
  • Sender: owner-wri-mathgroup at

> -----Original Message-----
> From:	Juan [SMTP:erfa11 at]
To: mathgroup at
> Sent:	Thursday, February 14, 2002 7:44 AM
> To:	mathgroup at
> Subject:	[mg32826] Iterators
> Hi,
> If I write:
> y = Table[Part[w,p[i]],{i,2}], then I get a message saying thet p[i] is
> not 
> a integer.
> How can I avoid that?
> I have to define w[[p[i]]] before I using it; p[i] are  iterators and w is
> a 
> list of numbers.Then, at the end,I can write:
> Table[{w[[p[1]]],w[[p[2]]},{p[1],a,b},{p[2],p[1],c}]
> This is becouse,the numbers of iterators are enter with the parameters in 
> the definition of the function, and you don't know that before.
> Thanks
> Juan
[Hartmut Wolf]  

In[1]:= w={w1,w2};

In[3]:= Table[w[[p[[i]]]],{i,1,2}]
Out[3]= {w2,w1}

In[4]:= w[[p]]      (*****)
Out[4]= {w2,w1}   

In[5]:= p=.
In[6]:= Table[w[[p[i]]],{p[i],1,2}]
Out[6]= {w1,w2}

I don't get that message, if p is Unset before. Otherwise it depends, look
at your exact message.

In[7]:= Table[{w[[p[i]]],w[[p[j]]]},{p[i],1,2},{p[j],1,2}]
Out[7]= {{{w1,w1},{w1,w2}},{{w2,w1},{w2,w2}}}

You meant something, but I failed to understand.

To learn what an iterator is, take this expression to your notebook and

  ButtonBox[\(What\ is\ an\ \(\(iterator\)\(\ \)\(?\)\)\),
      FrontEnd`FileName[ {$RootDirectory, "C:", "Programme", 
        "Wolfram Research", "Mathematica", "4.1", "Documentation",
        "MainBook"}, "1_05.nb", CharacterEncoding -> "WindowsANSI"],

Perhaps you need to adapt before 
   "Programme" --> "Program Files", "4.1" --> ?.?, "English" --> ?  

  • Prev by Date: Re: Very urgent problem...PLEASE help me!
  • Next by Date: FromBytes[]?
  • Previous by thread: Re: Iterators
  • Next by thread: Iterators