I understand that Attributes of Times make a bit non intuitive the Pattern Matching of its arguments. However I do not understand why this gives False:
MatchQ[Times[a, b, c], Times[___, b, ___]]
False
Can you explain it to me?
Mathematica Stack Exchange is a question and answer site for users of Wolfram Mathematica. It only takes a minute to sign up.
Sign up to join this communityTimes[___,b,___] // FullForm
Times[b,Power[BlankNullSequence[],2]]
MatchQ[Times[a, b, c], HoldPattern[Times[___, b, ___]]]
True
or
MatchQ[Times[a, b, c], Unevaluated[Times[___, b, ___]]]
True
HoldPattern[Times[___, b, ___]]
instead. If you look at theFullForm
ofTimes[___, b, ___]
you'll see that the attributes ofTimes
mucked up the pattern. $\endgroup$