Re: Working with indefinite number of variables

*To*: mathgroup at smc.vnet.net*Subject*: [mg129151] Re: Working with indefinite number of variables*From*: Cisco Lane <travlorf at yahoo.com>*Date*: Tue, 18 Dec 2012 02:39:04 -0500 (EST)*Delivered-to*: l-mathgroup@mail-archive0.wolfram.com*Delivered-to*: l-mathgroup@wolfram.com*Delivered-to*: mathgroup-newout@smc.vnet.net*Delivered-to*: mathgroup-newsend@smc.vnet.net

How about sum[x_, n_] := Sum[i*x[[i]], {i, 1, n}] As long as the x you provide has less than or equal to n parts, it will work. In[27]:= x = {a, "hello", \[Pi], 17} Out[27]= {a, "hello", \[Pi], 17} In[28]:= sum[x, 3] Out[28]= 2 "hello" + a + 3 \[Pi]