MapIndexed
Usage
• MapIndexed[f, expr] 把 f应用到 expr的元素中,并把每个元素的部分指定作为f 的第二个参数给出.
• MapIndexed[f, expr, levspec] 把 f应用到由levspec指定的 expr层上的所有部分.
Notes
• MapIndexed中 levelspec的缺省值为 {1}.
Further Examples
This applies f to each element in a list, giving the index of the element as a second argument to f.
In[1]:=
|
Out[1]=
|
This applies f to both levels in a matrix.
In[2]:=
|
Out[2]=
|
|