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:

Extract a part nested in an expression:

Extract parts from multiple positions:

Extract the parts given by Position:

Use an extract operator:

Extract a part from an Association:

Extract using different specifications:

Possible Issues  (1)

Extract[expr,{}] returns an empty list of subexpressions because the list of positions is empty:

Extract[expr,{{}}] extracts the subexpression at position {}, which is the whole expression:

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