此为 Mathematica 7 文档,内容基于更早版本的 Wolfram 语言
查看最新文档(版本11.1)

Pattern Sequences

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

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 a, b 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]=