Mathematica 9 is now available
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: [mg13510] Re: "Help please: Summing a list"
  • From: erra at esiea.fr (ERRA Robert)
  • Date: Fri, 31 Jul 1998 04:33:25 -0400
  • Organization: The Math Forum
  • References: <6pebm8$i6j@smc.vnet.net>
  • Sender: owner-wri-mathgroup at wolfram.com

Hello Rob,

in place of
PP[[i]]:=Sum[P[[n]],{n,0,i}];

use the following definition:

PP[i_]:=Sum[P[[n]],{n,1,i}]; (*1*)

or, if you really want to use the function PP with only integer
arguments, you can use
PP[i_Integer]:=Sum[P[[n]],{n,1,i}]; (*2) but in your case this is not a
problem to use (*1*). Take a look about definition of a function to
understand the use of i_ in place of i in the definition.
A Mathematica list begins always with the indice 1, if you ask P[[0]]
you will have the Head of P, i.e.

In[3]:=P[[0]]
gives
Out[3]:=List
Have a look at FullForm[P] to see why.

A bientôt,
Robert Erra.


  • Prev by Date: Overriding default rules
  • Next by Date: Mathematica and Win98?
  • Previous by thread: Overriding default rules
  • Next by thread: Mathematica and Win98?