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:

Wolfram Research (1988), Select, Wolfram Language function, https://reference.wolfram.com/language/ref/Select.html (updated 2014).

Text

Wolfram Research (1988), Select, Wolfram Language function, https://reference.wolfram.com/language/ref/Select.html (updated 2014).

CMS

Wolfram Language. 1988. "Select." Wolfram Language & System Documentation Center. Wolfram Research. Last Modified 2014. https://reference.wolfram.com/language/ref/Select.html.

APA

Wolfram Language. (1988). Select. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/Select.html

BibTeX

@misc{reference.wolfram_2024_select, author="Wolfram Research", title="{Select}", year="2014", howpublished="\url{https://reference.wolfram.com/language/ref/Select.html}", note=[Accessed: 17-December-2024 ]}

BibLaTeX

@online{reference.wolfram_2024_select, organization={Wolfram Research}, title={Select}, year={2014}, url={https://reference.wolfram.com/language/ref/Select.html}, note=[Accessed: 17-December-2024 ]}