Services & Resources / Wolfram Forums
-----
 /
MathGroup Archive
1998
*January
*February
*March
*April
*May
*June
*July
*August
*September
*October
*November
*December
*Archive Index
*Ask about this page
*Print this page
*Give us feedback
*Sign up for the Wolfram Insider

MathGroup Archive 1998

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

Search the Archive

Re: Help please: Summing a list

  • To: mathgroup at smc.vnet.net
  • Subject: [mg13513] Re: Help please: Summing a list
  • From: Hans Staugaard <hans.staugaard_NO_SPAM_ at _NO_SPAM_get2net.dk>
  • Date: Fri, 31 Jul 1998 04:33:27 -0400
  • Organization: Get2Net Internet Kunde
  • References: <6pebm8$i6j@smc.vnet.net>
  • Sender: owner-wri-mathgroup at wolfram.com

robpetersonSPAMME at iname.com skrev:
> 
> I make a list of numbers, eg:
> 
> P=Table[6,{x,0,110}]; (I have a more interesting list to use later if I
> get this working)
> 
> Now I want to make another list PP in which each entry PP[[i]] is the
> sum of P's first i entries.  I try
> 
> PP[[i]]:=Sum[P[[n]],{n,0,i}];
> 
> At the definition, I get the following error: Part::"pspec":
>     "Part specification \!\(n\) is neither an integer nor a list of
> integers."
> 
> I don't know how to make n an integer.  In the definition of Sum[], it
> seems n is an integer unless you add a forth parameter "di" in the
> specification list such as
> Sum[f, {i, imin, imax, di}]
> 
> Can anyone help me to generate this second list?
> 
> Thanks, Rob

I hope this can help you

In[11]:=
P=Range[10]

Out[11]=
{1,2,3,4,5,6,7,8,9,10}

In[12]:=
PP=FoldList[Plus,First[P],Rest[P]]

Out[12]=
{1,3,6,10,15,21,28,36,45,55}



  • Prev by Date: Re: abcd-matrix for lens-systems
  • Next by Date: Re: Help please: Summing a list
  • Previous by thread: Re: Help please: Summing a list
  • Next by thread: Re: Help please: Summing a list