Why did MatchQ[a + b + c, Plus[x_, y_] is considered true?
In my opinion, it should only consider 2 elements within Plus, such as MatchQ[a + b, Plus[_, _]] true.
Why is this MatchQ[a + b, Plus[_, _]] false?
Where did I get wrong? Please point out.
HoldPatternis simply not working. And How can I makeMatchQ[a + b, Plus[_, _]]true? – kile Feb 29 '20 at 13:02MatchQ[a + b, HoldPattern[Plus[_, _]]]works for me. – Leonid Shifrin Feb 29 '20 at 13:06MatchQ[(a + b + c), Plus[_, _, _]] // HoldPatternI am new toHoldPattern. Sorry for this. – kile Feb 29 '20 at 13:08HoldPatternis wrapped around the pattern which you don't want to evaluate. It may be a good idea for you to read more on the language core / basics. You can search this site for resources, there are plenty of recommendations. – Leonid Shifrin Feb 29 '20 at 13:11HoldPattern– Michael E2 Feb 29 '20 at 15:22