Extract

Extract[expr,pos]

extracts the part of expr at the position specified by pos.

Extract[expr,{pos1,pos2,}]

extracts a list of parts of expr.

Extract[expr,pos,h]

extracts parts of expr, wrapping each of them with head h before evaluation.

Extract[pos]

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

Details

Examples

open allclose all

Basic Examples  (6)

Extract the second part from an expression:

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

Extract a part nested in an expression:

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

Extract parts from multiple positions:

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

Extract the parts given by Position:

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

Use an extract operator:

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

Extract a part from an Association:

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

Extract using different specifications:

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

Possible Issues  (1)

See Also

Part  Take  PadLeft  ReplacePart

Tutorials

Introduced in 1996
(3.0)
| Updated in 2014
(10.0)