Re: Re: Product

```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>
• Prev by Date: Re: Re: Re: Player Pro and Packages
• Next by Date: A kernel, multiple notebooks, and Global?
• Previous by thread: Re: Product
• Next by thread: Re: Re: Product