Pick

Pick[list,sel]

picks out those elements of list for which the corresponding element of sel is True.

Pick[list,sel,patt]

picks out those elements of list for which the corresponding element of sel matches patt.

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.

Examples

open allclose all

Basic Examples  (2)

Pick out elements wherever a 1 appears in the "selector" list:

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

Pick out elements from a 2D array:

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

Scope  (4)

Generalizations & Extensions  (3)

Properties & Relations  (1)

Possible Issues  (3)

See Also

Cases  Part  Position  Boole  ListConvolve  Select  BitAnd

Tutorials

Introduced in 2004
(5.1)