Re: lists of variables

*To*: mathgroup at smc.vnet.net*Subject*: [mg58185] Re: lists of variables*From*: Bill Rowe <readnewsciv at earthlink.net>*Date*: Tue, 21 Jun 2005 06:03:16 -0400 (EDT)*Sender*: owner-wri-mathgroup at wolfram.com

On 6/20/05 at 5:21 AM, heathgerhardt at hotmail.com (Heath Gerhardt) wrote: >I need to make lists of variables, for example >{t1,t2,t3} >but have not been able to figure out how to make Mathematica do >this. Tried using You can create these variables as follows: ToExpression["t"<>ToString@#]&/@Range[3] >Array[t,3] >which gives >{t[1],t[2],t[3]} Which would be a list containing the function t to be evaluated at 1,2 and 3. >but then I don't know how to set the t[i]'s in expressions similar >to >F[t[1]_,t[2]_,t[3]_]:=Cos[t[1]+t[2]-t[3]] It isn't entirely clear from this what you want to do. I am going to assume what you are trying to do is set the variables you want created to specific values. Here is an example In[1]:= varList = (ToExpression["t"<>ToString@#]&/@Range[3]; Evaluate[varList] = Range[6, 8]; t1 Out[3]= 6 Note, this example assumes the variables t1,t2 and t3 do not have assigned values. If they did, this example will not work. This is because Mathematica will evaluate each of the variables and attempt to set the result of that evaluation to the values on the right hand side. Clearly, this isn't possible when t1 has been set to say 1. -- To reply via email subtract one hundred and four