This is documentation for Mathematica 3, which was
based on an earlier version of the Wolfram Language.
View current documentation (Version 11.1)
 Documentation / Mathematica / Built-in Functions / Programming / Pattern Matching  /
BlankNullSequence

  • ___ (three _ characters) or BlankNullSequence[ ] is a pattern object that can stand for any sequence of zero or more Mathematica expressions.
  • ___ h or BlankNullSequence[ h ] can stand for any sequence of expressions, all of which have head h.
  • Blank sequences work slightly differently depending on whether or not the head of the expression in which they appear is a symbol with the attribute Flat.
  • Consider matching the pattern f [ , , ... , ___, , ... ] against the expression f [ , , ... , , ... , , ... ]. If f is a symbol with attribute Flat, then the ___ will be taken to stand for the expression f [ , ... ]. If f is not a symbol with attribute Flat, then ___ will be taken to stand for the sequence of expressions , ... . With a named pattern, such as x ___, x can be used only as an element in an expression. The sequence of expressions , ... is "spliced in" to replace x, thereby usually increasing the length of the expression.
  • If ___ matches a sequence of length more than one, then the sequence will be represented by a Sequence object. In most uses of ___, however, the Sequence object will automatically be spliced into another expression, and will never appear explicitly.
  • See the Mathematica book: Section 2.3.8.
  • See also: Pattern, SlotSequence.

    Further Examples

    The triple blank indicates that the second argument to the function f can have any number of arguments (0, 1, 2, ...).

    In[1]:=

    In[2]:=

    Out[2]=

    In[3]:=

    Out[3]=