PatternTest


is a pattern object that stands for any expression that matches p, and on which the application of test gives True.

DetailsDetails

  • Any result for other than True is taken to signify failure.
  • The operator has a high precedence. Thus is , not .
  • In a form such as __?test, every element in the sequence matched by must yield True when test is applied.
  • PatternTest has attribute HoldRest.

ExamplesExamplesopen allclose all

Basic Examples  (3)Basic Examples  (3)

Find cases of any expression that satisfies the NumberQ test:

In[1]:=
Click for copyable input
Out[1]=

Test whether a list has only positive elements:

In[1]:=
Click for copyable input
Out[1]=
In[2]:=
Click for copyable input
Out[2]=

Create a definition that only applies to numeric arguments:

In[1]:=
Click for copyable input
In[2]:=
Click for copyable input
Out[2]=
In[3]:=
Click for copyable input
Out[3]=
In[4]:=
Click for copyable input
Out[4]=
Introduced in 1988
(1.0)