Blank
✖
Blank
Background & Context
- Blank is a pattern object that can stand for any expression in the Wolfram Language. The expression Blank[] may be compactly denoted with the underscore character _. The more specific pattern Blank[h] (compactly denoted
) stands for any expression with head h. Blank is an extremely powerful and useful construct for pattern-based programming and is the foundation upon which pattern-matching functionality is built. The most common function taking Blank and related patterns as arguments is SetDelayed. Other such functions include MatchQ, Cases, DeleteCases, Count, and RuleDelayed.
- Sequences of one or more blanks are represented using the pattern object BlankSequence (double underscore: __). Sequences of zero or more blanks are represented using the pattern object BlankNullSequence (triple underscore: ___). In general, patterns involving multiple instances of Blank are faster to work with than those involving BlankSequence and BlankNullSequence, since vastly more possibilities must be tested for a possible match in the latter two cases.
- Blank may be used together with Optional to specify a pattern object for an expression which, if omitted, is replaced by a default value. The Alternatives pattern object allows specification of several possible patterns, including Blank. Blank may be combined with a PatternTest (written in shorthand as
). For example, the code Cases[Range[100], _?(IntegerQ[Sqrt[#]] &)]] (which makes use of a pure function with a Slot specification) selects and returns the list of all square numbers less than or equal to 100.
Examples
Basic Examples (2)Summary of the most common use cases
A pattern that matches any expression:
In[1]:=1

✖
https://wolfram.com/xid/0giv8s-b3gg62
Out[1]=1

A pattern that matches any symbol:
In[2]:=2

✖
https://wolfram.com/xid/0giv8s-i06ruq
Out[2]=2

A function definition that will take any single argument:
In[1]:=1

✖
https://wolfram.com/xid/0giv8s-banjmp
In[2]:=2

✖
https://wolfram.com/xid/0giv8s-e7303a
Out[2]=2

A function definition for integer arguments only:
In[3]:=3

✖
https://wolfram.com/xid/0giv8s-nkff4x
In[4]:=4

✖
https://wolfram.com/xid/0giv8s-h7lgit
Out[4]=4

Wolfram Research (1988), Blank, Wolfram Language function, https://reference.wolfram.com/language/ref/Blank.html.
✖
Wolfram Research (1988), Blank, Wolfram Language function, https://reference.wolfram.com/language/ref/Blank.html.
Text
Wolfram Research (1988), Blank, Wolfram Language function, https://reference.wolfram.com/language/ref/Blank.html.
✖
Wolfram Research (1988), Blank, Wolfram Language function, https://reference.wolfram.com/language/ref/Blank.html.
CMS
Wolfram Language. 1988. "Blank." Wolfram Language & System Documentation Center. Wolfram Research. https://reference.wolfram.com/language/ref/Blank.html.
✖
Wolfram Language. 1988. "Blank." Wolfram Language & System Documentation Center. Wolfram Research. https://reference.wolfram.com/language/ref/Blank.html.
APA
Wolfram Language. (1988). Blank. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/Blank.html
✖
Wolfram Language. (1988). Blank. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/Blank.html
BibTeX
✖
@misc{reference.wolfram_2025_blank, author="Wolfram Research", title="{Blank}", year="1988", howpublished="\url{https://reference.wolfram.com/language/ref/Blank.html}", note=[Accessed: 24-March-2025
]}
BibLaTeX
✖
@online{reference.wolfram_2025_blank, organization={Wolfram Research}, title={Blank}, year={1988}, url={https://reference.wolfram.com/language/ref/Blank.html}, note=[Accessed: 24-March-2025
]}