Murray Eisenberg wrote:
> But of course Total is also redundant! Plus @ {1,2,3,4}
>
> So the issue is one of language design: when does a particular case of a
> more general construction occur so frequently that a special function
> should be introduced for it.
Total[] and Accumulate[] are not completely redundant. Total[] is
faster than Plus @@ # &, and also less precise by default. When using
Total[] or Accumulate[], one has the option to choose between a faster
and a more precise (Method -> "CompensatedSummation") summation method.
Personally I think that the *syntax* Total[list] provides nothing over
Plus @@ list, so just because summation is a common operation, a new
syntax should not be introduced for it. In fact I would consider the
introduction of too many redundant constructs bad language design.
Note that faster algorithms for special cases *can* be implemented
without a new syntax/new function. Mathematica does exactly this for
many operations. But the syntax Plus @@ list or FoldList[Plus, 0, list]
cannot (should not?) be extended to allow for selecting between two
algorithms just for the special case of summation. Thus the
introduction of Total[] and Accumulate[] was legitimate. These two
functions do not only provide a new syntax, but also new functionality.
>
> Szabolcs Horv=E1t wrote:
>> Steven wrote:
>>> Silly beginner's question: is there a function to multiply all elements of a
>>> list, like Total does for addition?
>> No, there isn't. But it would be redundant anyway because it is very
>> easy to build your own:
>>
>> In[1]:= Times @@ {1, 2, 3, 4, 5}
>> Out[1]= 120
>>
>> Look up Apply in the documentation.
>>