Message Boards Message Boards

2
|
5482 Views
|
2 Replies
|
7 Total Likes
View groups...
Share
Share this post:

What's the secret to matching Condition?

What trick do I have to use to write a pattern that matches Condition? These don't work:
MatchQ[Hold[a := b /; c], Hold[_ := _ /; _]]
MatchQ[Hold[b /; c], Hold[_ /; _]]
MatchQ[Hold[b /; c], HoldPattern[Hold[_ /; _]]]
MatchQ[Hold[b /; c], Verbatim[Hold[_ /; _]]]
2 Replies
The first 2 don't work because the Condition on the rhs is interpreted as a condition.

The third one doesn't work because HoldPattern doesn't prevent the interpretation of Condition, merely evaluations.

The last one doesn't work because Verbatim means literally. So this also stops Blank[] from matching anything but a literal Blank[].

The following also works:
In[1]:= MatchQ[Hold[b /; c], Hold[_Condition]]
Out[1]= True 
POSTED BY: Jeremy Michelson
MatchQ[Hold[b /; c], Hold[Verbatim[Condition][_, _]]]
POSTED BY: Carlo Barbieri
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract