

Pick
Details

- sel can be a nested list of any depth.
- Pick[list,sel,patt] picks out those list[[i1,i2,…]] for which sel[[i1,i2,…]] matches patt.
- Depending on the arrangement of elements matching patt in a nested list sel, Pick may return a ragged array.
- The heads in list and sel do not have to be List.
- Pick works with SparseArray objects.
- If sel is a DataStructure object of type "BitVector", Pick[list,sel] retrieves the elements of list corresponding to the value 1 in sel. »
- Parallelize[Pick[list,sel]] computes Pick[list,sel] in parallel on all subkernels. »
Examples
open all close allBasic Examples (2)
Scope (5)
Pick out elements wherever True appears in the "selector" list:
Pick elements whose parts match a pattern:
Use a SparseArray to select arguments:
Pick elements from a SparseArray:
Create a data structure of type "BitVector" and length five:
Set its second and fourth bits to 1, cognizant of the fact that it is 0-indexed rather than 1-indexed:
Generalizations & Extensions (3)
Applications (1)
Use Pick with a normal list of True and False:
The same operation using the corresponding DataStructure is much faster:
Properties & Relations (3)
The comparison in Pick[list,sel,patt] is purely structural, with no regard to heads:
f[b] is selected because the 3,1 part of sel matches the patt:
The corresponding part of list, if it exists, will be picked, along with its heads:
Note that the 2,1 part of sel also matches patt:
However, there is no corresponding part of list to be picked:

Compute Pick in parallel:
If sel is a bit vector, Pick[list,sel] retrieves the elements of list corresponding to the value 1 in sel:
Possible Issues (4)
The "selector" list has to have the same length and structure as the data:

Atomic expressions are allowed in Pick:
This is because all parts—including the empty part—are tested for matching:
If there is an atomic argument and it is not picked in its entirety, Sequence[] is returned:
This applies equally to the second argument:
Using Except[c] in the third argument can lead to unexpected results:
The whole expression is returned because the entire selector argument matches the pattern:
Use Except[c,p] to restrict the pattern to elements of the selector argument:
Using nonatomic expressions in the selector argument can lead to unexpected results:

Applying the test beforehand so the list only contains True and False avoids the structure issue:
Tech Notes
Related Guides
History
Introduced in 2004 (5.1) | Updated in 2025 (14.3)
Text
Wolfram Research (2004), Pick, Wolfram Language function, https://reference.wolfram.com/language/ref/Pick.html (updated 2025).
CMS
Wolfram Language. 2004. "Pick." Wolfram Language & System Documentation Center. Wolfram Research. Last Modified 2025. https://reference.wolfram.com/language/ref/Pick.html.
APA
Wolfram Language. (2004). Pick. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/Pick.html
BibTeX
@misc{reference.wolfram_2025_pick, author="Wolfram Research", title="{Pick}", year="2025", howpublished="\url{https://reference.wolfram.com/language/ref/Pick.html}", note=[Accessed: 13-August-2025]}
BibLaTeX
@online{reference.wolfram_2025_pick, organization={Wolfram Research}, title={Pick}, year={2025}, url={https://reference.wolfram.com/language/ref/Pick.html}, note=[Accessed: 13-August-2025]}