Mathematica 9 is now available
THIS IS DOCUMENTATION FOR AN OBSOLETE PRODUCT.
SEE THE DOCUMENTATION CENTER FOR THE LATEST INFORMATION.
Mathematica > Core Language > List Manipulation > Elements of Lists >
Mathematica > Data Manipulation > Handling Arrays of Data > Elements of Lists >

Select

Select[list, crit]
picks out all elements ei of list for which crit[ei] is True.
Select[list, crit, n]
picks out the first n elements for which crit[ei] is True.
  • The object list can have any head, not necessarily List.
Select elements that are even:
Use a pure function to test each element:
Return only the first expression selected:
Select elements that are even:
In[1]:=
Click for copyable input
Out[1]=
 
Use a pure function to test each element:
In[1]:=
Click for copyable input
Out[1]=
 
Return only the first expression selected:
In[1]:=
Click for copyable input
Out[1]=
Select picks out elements for which applying the criterion explicitly yields True:
Applying the criterion to the symbolic object x does not explicitly yield True:
Select works with any head, not just List:
Select works with SparseArray objects:
The result may be a list if it is not sparse:
Select numbers up to 100 that equal 1 modulo both 3 and 5:
Select 4-tuples that read the same in reverse:
Find the first four 3x3 matrices of 0s and 1s that have determinant 1:
Select eigenvalues that lie within the unit circle:
Find built-in Mathematica objects whose names are less than 3 characters long:
Select numeric quantities from a product:
Find an approximation to Pi by finding the proportion of points that lie within a disk:
Select is similar to Cases except that it uses a function instead of a pattern:
Select the lists that have sum of elements less than 10:
Use Cases to get the same result:
New in 1 | Last modified in 5
Ask a question about this page  |  Suggest an improvement  |  Leave a message for the team