Services & Resources / Wolfram Forums
-----
 /
MathGroup Archive
2006
*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 2006

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

Search the Archive

Re: Summing elements within a List or Array

  • To: mathgroup at smc.vnet.net
  • Subject: [mg69728] Re: Summing elements within a List or Array
  • From: "John Adeosun" <jtadeosun at yahoo.com>
  • Date: Thu, 21 Sep 2006 07:31:57 -0400 (EDT)
  • References: <eebfs6$57q$1@smc.vnet.net> <eee0i8$6h0$1@smc.vnet.net>

Thanks for the useful suggestion...It works well.
John.
<dimmechan at yahoo.com> wrote in message news:eee0i8$6h0$1 at smc.vnet.net...
> ***You can work as follows:
>
> In[96]:=
> Flatten[Apply[Plus,alist,1],1]
> Out[96]=
> {0,1.2,3.5,6.9}
>
> ***or in compact form
>
> In[95]:=
> Plus@@@alist//Flatten
> Out[95]=
> {0,1.2,3.5,6.9}
>
> ***As you can see in the Help Browser and also in (Ted Ersek's Tips and
> Tricks)
> http://www.verbeia.com/mathematica/tips/HTMLLinks/Tricks_A-K_3.html
>
> ***(f@@lst)  is normally equivalent to Apply[f, expr] and  (f@@@lst)
> is normally equivalent to Apply[f, lst, 1] as demonstrated below
>
> In[103]:=
> lst={1,2,3};
>
> ln[104]:=
> {Apply[f,lst]==f@@lst,Apply[f,lst,1]==f@@@lst}
> Out[104]=
> {True,True}
>
> ***BTW can you tell me how you generate your alist within Mathematica?
>
>
> Dimitris Anagnostou
>
>
> ÎY/Î- John Adeosun έγÏ?αÏ^ε:
>> Hello Everyone,
>>
>> I generated an intended list of real numbers using Mathematica 5.2, say
>> "alist", that looks like:
>>
>> alist = {{0}, {{1.2},0}, {{2.3},{1.2},0},{{3.4},{2.3},{1.2},0},
>> ................{{99.0},{98.9},{97.8},.......,0}}
>> (In Matrix form, this "alist" can be shown as a LowerDiagonal Matrix)
>>
>> Meanwhile, my present goal is to then program using Mathematica to obtain 
>> a
>> list, say "aalist", having each element equal to the sum of the elements 
>> in
>> each(corresponding) sublist of the original list "alist." That is,
>>
>> aalist  = {0, 1.2, 3.5, 6.9,...........}
>>
>> In essence, it is like reducing, say, 100 by 100 matrix to 100 by 1 
>> matrix
>> via summing operation.
>>
>>  I programmed using some summing operations/functions in Mathematica to 
>> no
>> avail. I don't know what I 'm doing wrong.
>>
>> Can anyone help with this problem?
>>
>> Thanks,
>>
>> John.
> 



  • Prev by Date: Re: Re: General--Mathematica and Subversion
  • Next by Date: Re: Re: Why is the negative root?
  • Previous by thread: Re: Summing elements within a List or Array
  • Next by thread: partials of Sum[x[i]^2, {i,1,n}] (e.g.)