Group Abstract Group Abstract

Message Boards Message Boards

0
|
3.7K Views
|
1 Reply
|
3 Total Likes
View groups...
Share
Share this post:

Why is this pattern checking true?

Consider the following code:

MatchQ[Cycles[{{1, 2}}] ** (Cycles[{{1, 2}}]), 
     NonCommutativeMultiply[a___, Cycles[x_], Plus[y__], b___]]

There is no plus there, how can this be true? Thanks

POSTED BY: Haolin Li
Posted 6 years ago

If Plus is given a single argument it just returns the argument.

In[1]:= Plus[3]
Out[1]= 3

So if the single argument is a pattern, the unchanged pattern will be returned.

Therefore:

In[2]:= MatchQ[u*w, Times[a_, Plus[b_]]]
Out[2]= True
POSTED BY: Hans Milton
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard