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


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

Re: Working with indefinite number of variables

From Cisco Lane <travlorf@yahoo.com>
Newsgroups comp.soft-sys.math.mathematica
Subject Re: Working with indefinite number of variables
Date 2012-12-18 07:35 +0000
Message-ID <kap6bv$465$1@smc.vnet.net> (permalink)
Organization Time-Warner Telecom

Show all headers | View raw


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 comp.soft-sys.math.mathematica | Previous | Next | Find similar | Unroll thread


Thread

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

csiph-web