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.

Select[crit]

represents an operator form of Select that can be applied to an expression.

Details

Examples

open allclose all

Basic Examples  (5)

Select elements that are even:

Use a pure function to test each element:

Return only the first expression selected:

Use the operator form of Select:

Select operates on values in an Association:

Scope  (5)

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:

Find pairs containing x:

Find up to 2 pairs containing x:

Fewer than the requested elements may be returned:

Use an operator form as selection criterion:

Use Select in operator form:

Generalizations & Extensions  (2)

Select works with any head, not just List:

Select works with SparseArray objects:

The result may be a list if it is not sparse:

Applications  (7)

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 3×3 matrices of 0s and 1s that have determinant 1:

Select eigenvalues that lie within the unit circle:

Find built-in Wolfram Language objects whose names are less than 3 characters long:

Select numeric quantities from a product:

Find an approximation to by finding the proportion of points that lie within a disk:

Properties & Relations  (3)

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:

Select elements that are even:

Separate odd and even elements:

Construct an association that explicitly contains as keys the results of the criterion function:

Compute Select in parallel:

RelatedLinks-NKS.png

RelatedLinks-NKS.png

RelatedLinks-NKS.png

RelatedLinks-NKS.png

RelatedLinks-NKS.png

RelatedLinks-NKS.png

RelatedLinks-NKS.png

RelatedLinks-NKS.png

RelatedLinks-NKS.png

RelatedLinks-NKS.png

RelatedLinks-NKS.png