Re: Re: Product
- To: mathgroup at smc.vnet.net
- Subject: [mg87664] Re: [mg87592] Re: Product
- From: Andrzej Kozlowski <akoz at mimuw.edu.pl>
- Date: Tue, 15 Apr 2008 05:51:48 -0400 (EDT)
- References: <200804110542.BAA04653@smc.vnet.net> <200804121059.GAA00044@smc.vnet.net> <ftsd2p$bca$1@smc.vnet.net> <200804140941.FAA07966@smc.vnet.net> <234CB1EF-7890-4173-94F9-8998DFC54BED@mimuw.edu.pl> <f831b3d60804140842o15ca844dpaa3832a8a2b55de9@mail.gmail.com>
On 15 Apr 2008, at 00:42, Szabolcs Horv=E1t wrote:
> On Mon, Apr 14, 2008 at 3:13 PM, Andrzej Kozlowski
> <akoz at mimuw.edu.pl> wrote:
>>
>>> But of course in principle there is nothing that would make it
>>> impossible to introduce a special case for functions like Times and
>>> Plus, and make them work with packed arrays. So this alone does not
>>> make it necessary to introduce a new syntax/new function, like
>>> Total[].
>>>
>>
>> Well, I never claimed that it did.
>
> I didn't mean that you did :-)
>
>> It seems to me that WRI wanted to add
>> new functionality to Mathematica and modifying Plus would break too
>> many
>> things. For example, Total, in version 6 accepts level
>> specifications, so:
>>
>> Total[{{a, b}, {c, d}}, {2}]
>> {a + b, c + d}
>>
>> while
>>
>> Apply[Plus, {{a, b}, {c, d}}, {2}]
>> {{a, b}, {c, d}}
>>
>> The key thing, in my opinion, is that Total[list] is just a spacial
>> case of
>> Total (=Total[list,1]) and the general case of Total would be quite
>> hard or
>> impossible to define using Apply and Plus.
>>
>
> Actually one just needs to shift the level specification by 1, so
>
> Total[{{a, b}, {c, d}}, {2}] is equivalent to Apply[Plus, {{a, b},
> {c, d}}, {1}]
>
> Generally,
>
> Total[expression, {n}] is equivalent to Apply[Plus, expression,
> {n-1}]
>
> and
>
> Total[expression, n] is equivalent to Apply[Plus, expression, {0,
> n-1}]
>
> Szabolcs Horv=E1t
Yes, you are right, of course. (I gues I should stop posting replies
whose conents consist of the first thing that comes to my mind, but I
usually do not have the time for much more).
Level specifications are certianly not the reason for having Total
(though I find them a bit more convenient to use - which is what made
me make that silly claim). I guess the reason was just the feeling
that the syntax of Apply and Plus was just a bit too convoluted.
Andrzej
- References:
- Product
- From: "Steven" <steven_504@telenet.be>
- RE: Product
- From: "Jose Luis Gomez" <jose.luis.gomez@itesm.mx>
- Re: Product
- From: Szabolcs Horvát <szhorvat@gmail.com>
- Product