RE : Sum of list elements
- To: mathgroup at smc.vnet.net
- Subject: [mg49316] RE : [mg49313] Sum of list elements
- From: "Florian Jaccard" <florian.jaccard at eiaj.ch>
- Date: Tue, 13 Jul 2004 05:54:06 -0400 (EDT)
- Sender: owner-wri-mathgroup at wolfram.com
Is this what you want ? In[193]:= liste={2,2,1}; In[195]:= Plus@@liste Out[195]= 5 In[196]:= 1/Plus@@liste*liste Out[196]= {2/5, 2/5, 1/5} Meilleures salutations F.Jaccard -----Message d'origine----- De : Per Rønne [mailto:spam at husumtoften.invalid] Envoyé : mardi, 13. juillet 2004 10:33 À : mathgroup at smc.vnet.net Objet : [mg49313] Sum of list elements I'm trying to find a function [possibly a way to make a function] which calculate the sum of the elements of a list. Right now, the purpose is to find the relative distribution of the elements of a list. That is, I need a way to get out that the distribution of: {2, 2, 1} is {2/5, 2/5, 1/5}. Had I been able to get the sum of the list elements in this way: Sum[{2, 2, 1}] it could had been done with: l = {2, 2, 1} l / Sum[l] -- Per Erik Rønne