|
SOLUTIONS
|
BUILT-IN MATHEMATICA SYMBOL
Part 
or Part[expr, i]
gives the i
part of expr.
![]()
counts from the end.
or Part[expr, i, j, ...]
is equivalent to
.
![]()
gives a list of the parts
,
, ... of expr.
gives parts m through n.
gives parts m through n in steps of s.
DetailsDetails
- You can make an assignment like
to modify any part or sequence of parts in an expression. » - Part 0 of an expression is its head.
- Common spans of parts include:
-
expr[[m;;]] part m through the end expr[[;;n]] from the beginning to part n expr[[;;,j]] column j expr[[m1;;n1,m2;;n2]] submatrix - When expr is a list,
gives a list of parts. In general, the head of expr is applied to the list of parts. » - You can get a nested list of parts from
. Each part has one index from each list. - If any of the
are All or
, all parts at that level are kept. - Notice that lists are used differently in Part than in functions like Extract, MapAt, and Position.
- If expr is a SparseArray object,
gives the parts in the corresponding ordinary array. » - In StandardForm and InputForm,
can be input as
.
and
can be entered as Esc[[Esc and Esc]]Esc or \[LeftDoubleBracket] and \[RightDoubleBracket]. - In StandardForm,
can be input as
or
.
ExamplesExamplesopen allclose all
Basic Examples (10)Basic Examples (10)
| In[1]:= |
| Out[1]= |
| In[1]:= |
| Out[1]= |
| In[1]:= |
| Out[1]= |
| In[1]:= |
| Out[1]= |
The second column of a matrix:
| In[1]:= |
| Out[1]= |
An element 2 from the end of a list:
| In[1]:= |
| Out[1]= |
| In[1]:= |
| Out[1]= |
| In[1]:= |
| Out[1]= |
| In[2]:= |
| Out[2]= |
| In[3]:= |
| Out[3]= |
| In[1]:= |
| Out[1]= |
| In[2]:= |
| Out[2]= |
| In[3]:= |
| Out[3]= |
Part works with expressions of any kind, not just lists:
| In[1]:= |
| Out[1]= |
| In[2]:= |
| Out[2]= |
| In[3]:= |
| Out[3]= |
Part always operates on the FullForm of expressions:
| In[4]:= |
| Out[4]= |
| In[5]:= |
Out[5]//FullForm= | |
New in 1 | Last modified in 6
Mathematica 9 is now available!
New to Mathematica?
Find your learning path »
Have a question?
Ask support »
