Total has been changed in Mathematica 12.0. The documentation seems to contradict itself. In one line it states:
Total[ $f[ e_1,e_2,...]$ ] gives the sum of the $e_i$ for any head $f$
In the next line one reads:
By default, Total only adds up elements inside List, SparseArray, StructuredArray and Association.
As a matter of fact, in Mathematica 12.0 Total[ f[a,b] ]
does not evaluate to a+b
as it did in Mathematica 11.3.
Instead, the new option AllowedHeads
was introduced and one can for example write now Total[f[a,b], AllowedHeads->Inherited]
for obtaining the old output.
This is a breaking change. I wonder if this was intended by Wolfram?
AllowedHeads
is illegal in V11.3 and permissible now in V12, I'd say the change was clearly intended. You could useSetOptions[Total, AllowedHeads -> Inherited]
as a general workaround. (It seems the documentation could use a good copy editor.) $\endgroup$Total[expr]
was supposed to be equivalent toPlus @@ epxr
. $\endgroup$