I was surprised by the following behavior of
PatternTest and I think that this may be instructive for other people too.
FreeQ[x], an operator that returns
True if its operand does not contain x. E.g.
Now look at:
MatchQ[2 , _?FreeQ[x]] False
Not what I ecpected. However, if we put brackets around
MatchQ[2 , _?(FreeQ[x])] True
With the help of Wolfram support I could finally entangle this mystery. The
PatternTest has a pretty high precedence, higher than
Part, so that
_?FreeQ[x] is interpreted as
(_?FreeQ)[x] and not as expected: