Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.soft-sys.math.mathematica > #12842 > unrolled thread

Re: Working with indefinite number of variables

Started byCisco Lane <travlorf@yahoo.com>
First post2012-12-18 07:35 +0000
Last post2012-12-18 07:35 +0000
Articles 1 — 1 participant

Back to article view | Back to comp.soft-sys.math.mathematica


Contents

  Re: Working with indefinite number of variables Cisco Lane <travlorf@yahoo.com> - 2012-12-18 07:35 +0000

#12842 — Re: Working with indefinite number of variables

FromCisco Lane <travlorf@yahoo.com>
Date2012-12-18 07:35 +0000
SubjectRe: Working with indefinite number of variables
Message-ID<kap6bv$465$1@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]

[toc] | [standalone]


Back to top | Article view | comp.soft-sys.math.mathematica


csiph-web