{g[x, y, z], h[x, y], f[]} /. (f_[t___] /; f != List) :> Plus[t]
Why is the output of this expression
{g[x, y, z], h[x, y], f[]}
instead of
{x+y+z,x+y,0}
When I change the code to
{g[x, y, z], h[x, y], f[]} /. (f_[t___] /; f =!= List) :> Plus[t]
everything works as I expected
SameQ
andEqual
. Instead of repeating things, please see this difference-between-and-in-mathematica which talks about the difference between SameQ and Equal. This applies exactly toUnSameQ
andUnequal
. $\endgroup$True
, is consideredFalse
.Equal
does not evaluate, so there is no match. All these bits can actually also be found in the book (but not in one place), although perhaps I could have elaborated more on this particular example you picked. $\endgroup$