Mathematica 9 is now available
THIS IS DOCUMENTATION FOR AN OBSOLETE PRODUCT.
SEE THE DOCUMENTATION CENTER FOR THE LATEST INFORMATION.
Virtual Book > Core Language > Patterns > Pattern Sequences >

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.
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]=
Ask a question about this page  |  Suggest an improvement  |  Leave a message for the team
Format:   HTML  |  CDF