MathGroup Archive 2002

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

Search the Archive

RE: Iterators

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

> -----Original Message-----
> From:	Juan [SMTP:erfa11 at hotmail.com]
To: mathgroup at smc.vnet.net
> Sent:	Thursday, February 14, 2002 7:44 AM
> To:	mathgroup at smc.vnet.net
> 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]  
look:

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

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
click

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

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