From the statement in the documentation:
Extract[expr,{i,j,…}] is equivalent to Part[expr,i,j,…].
So basically Extract
is just a listable version of Part
. So I look at the following example:
expr = f[g[1, 2], {h[3],i[4]}];
Let's take some parts out as follows:
{Part[expr,1,2],Part[expr, 2, All, 1]}
{2, {3, 4}}
Now I try to combine the multiple Part
s using a single Extract
:
{Extract[expr,{1,2}], Extract[expr,{2,All,1}]}
Extract[expr, {{1, 2}, {2, All, 1}}]
and it fails. But why? Isn't it the purpose of Extract
to be able to combine multiple Part
s commands into a single Extract
?
Issue recently discussed on Live CEOing Ep 488: Language Design in Wolfram Language [SubValues, List, Extract and More] and a potential solution may be coming in a future version.
All
is not a position per se. Neither is aSpan[]
. The purpose ofExtract
is to extract parts found byPosition
. (The previous sentence is my opinon, not necessarily a fact.) -- There's alsoExtract[expr, {p1, p2,...}, Hold]
, whichPart
does not do. $\endgroup$Extract
has an operator form,Part
does not. $\endgroup$Extract
have the same form as those returned byPosition
" $\endgroup$