Let's say I have four functions: x, y, X`x, and X`y. Writing a pattern that matches x, but not X`x is easy
f[_x] := True; f[_] := False { f[x[]], f[X`x[]] } (* {True, False} *) and the reverse is also straightforward
g[_X`x] := True; g[_] := False { g[x[]], g[X`x[]] } (* {False, True} *) But, how would I match all members of X`?
Obviously, this works
h[_?(MemberQ[Names["X`*"], ToString@Head@#] &)] := True h[_] := False { h[x[]], h[X`x[]], h[X`y[]] } (* {False, True, True} *) but it seems excessive, especially if the Context contains a large number of functions.