Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.soft-sys.math.mathematica > #12842 > unrolled thread
| Started by | Cisco Lane <travlorf@yahoo.com> |
|---|---|
| First post | 2012-12-18 07:35 +0000 |
| Last post | 2012-12-18 07:35 +0000 |
| Articles | 1 — 1 participant |
Back to article view | Back to comp.soft-sys.math.mathematica
Re: Working with indefinite number of variables Cisco Lane <travlorf@yahoo.com> - 2012-12-18 07:35 +0000
| From | Cisco Lane <travlorf@yahoo.com> |
|---|---|
| Date | 2012-12-18 07:35 +0000 |
| Subject | Re: 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]
Back to top | Article view | comp.soft-sys.math.mathematica
csiph-web