BlankSequence
__
matches any sequence of one or more expressions.
__head
matches any sequence of one or more expressions, each with a Head
of head
.
Attributes[BlankSequence] := {Protected}
Simple examples
In[1]:= MatchQ[a + b + c, a + b + __] Out[1]= True
In[2]:= MatchQ[a + b + c, a + b + c + __] Out[2]= False
Further examples
With head assertions:
In[1]:= MatchQ[a*b, __Symbol] Out[1]= False
In[2]:= MatchQ[a*b, x__Symbol] Out[2]= False
In[3]:= MatchQ[a, __Symbol] Out[3]= True
In[4]:= MatchQ[a*b, x__Times] Out[4]= True
In[5]:= MatchQ[a*b, x__Plus] Out[5]= False
In[6]:= MatchQ[a + b, x__Plus] Out[6]= True