MathGroup Archive 2012

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

Search the Archive

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]



  • Prev by Date: Re: How to use FindMaximum with a parameter passed to NDSolve??
  • Next by Date: Terrible unit trouble in Mathematic 9
  • Previous by thread: Re: Working with indefinite number of variables
  • Next by thread: how to define step size in FindMinimum