If I run the following code:
Do[ Print["*** ", HoldForm[x] /. x -> a, " ***"]; Print["Replace: ", (HoldForm[x] /. x -> a) /. {n1 -> 1, n2 -> 2, n3 -> 3}]; Print["FullForm: ", FullForm[a]]; , {a, {n1 n2, -n1 n2, n1 n2 n3}} ] I get
*** n1 n2 *** Replace: 1 x 2 FullForm: Times[n1,n2] *** -n1 n2 *** Replace: -2 FullForm: Times[-1,n1,n2] *** n1 n2 n3 *** Replace: 2 x 3 FullForm: Times[n1,n2,n3]
I kind of understand what is going on, but I would like the output in the second case to be -1 x 2 and in the third case 1 x 2 x 3. How do I do that?
Times[]. (Similarly, $0$ is quickly removed inPlus[].) Perhaps you want something likeInactivate[Times[1, 2, 3], Times]? $\endgroup$1, notTimes, andInactivate[1]is just the same as1. However, your solution inspired me to find a solution of my own, which I will post now. $\endgroup$