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 make
MatchQ[a + b, Plus[_, _]]true? $\endgroup$
MatchQ[a + b, HoldPattern[Plus[_, _]]]works for me. $\endgroup$
MatchQ[(a + b + c), Plus[_, _, _]] // HoldPatternI am new to
HoldPattern. Sorry for this. $\endgroup$
HoldPatternis 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. $\endgroup$