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 >

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.
  • 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 out elements wherever a 1 appears in the "selector" list:
Pick out elements from a 2D array:
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]=
Pick out elements wherever True appears in the "selector" list:
The data does not have to be a list:
The "selector" list has to have the same length and structure as the data:
New in 5.1
Ask a question about this page  |  Suggest an improvement  |  Leave a message for the team