{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
SameQandEqual. Instead of repeating things, please see this difference-between-and-in-mathematica which talks about the difference between SameQ and Equal. This applies exactly toUnSameQandUnequal. – Nasser Nov 02 '14 at 04:00True, is consideredFalse.Equaldoes 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. – Leonid Shifrin Nov 02 '14 at 04:06