Pattern Sequences

In some cases you may need to specify pattern sequences that are more intricate than things like or x..; for such situations you can use PatternSequence[p1,p2,].

PatternSequence[p1,p2,]a sequence of arguments matching

Pattern sequences.

This defines a function with two or more arguments, grouping the first two.
In[1]:=
Click for copyable input
Evaluate the function for different numbers of arguments.
In[2]:=
Click for copyable input
Out[2]=
This picks out the longest run of the sequence in the list.
In[3]:=
Click for copyable input
Out[3]=

The empty sequence, PatternSequence[], is sometimes useful to specify an optional argument.

This picks out expressions with exactly one or two arguments.
In[4]:=
Click for copyable input
Out[4]=