Using Mathematica 11 when I define a list
yy = {x*43, 32*y};
and then convert it to a sum
yy[[0]] = Plus;
yy
I get, as expected, x*43 + 32*y.
However, as soon as I try to multiply my sum with a minus sign, i.e. when I execute
-yy
my kernel quits without any error message.
Any ideas why this happens and how to avoid it?
The problem can be avoided by converting the list using a Do loop:
sum = 0;
Do[
sum = sum + yy[[i]],
{i, Length[yy]}
];
sum
-sum
(* 43 x + 32 y *)
(* -43 x - 32 y *)
Tr
orTotal
orPlus @@
are more idiomatic thanDo
. And all work. $\endgroup$-2 yy
works just fine.-2 yy/2
crashes the kernel again, and so doesI I yy
. $\endgroup$