MapAt
Usage
• MapAt[f, expr, n] 把 f 应用到expr中位置 n 上的元素中. 如果 n 为负数, 该位置从末尾开始倒着计数.
• MapAt[f, expr, i, j, ... ] 把 f 应用到 expr 中位置 i, j, ...  上的元素中.
• MapAt[f, expr,   , , ... ,  , , ... , ... ] 把 f 应用到 expr 几个位置的部分中.
Notes
• MapAt[f, expr, i, j, ... ] 或 MapAt[f, expr,  i, j, ...  ] 把 f 应用到 expr[[i, j, ... ]]部分. • MapAt[f, expr,   , , ... ,  , , ... , ... ] 把 f 应用到 expr[[ , , ... ]], expr[[ , , ... ]], ...等部分. • MapAt 使用的位置列表同函数 Position 返回的列表具有同样的形式. • 如果某个部分在位置列表中提到不止一次,MapAt会把 f 重复应用到这个特殊部分.
Further Examples
This specifies that f is mapped across the list at position only.
In[1]:=
|
Out[1]=
|
Here f is mapped on the second position of the first element.
In[2]:=
|
Out[2]=
|
To avoid ambiguity when there is more than one part specification, you must put each of them in a separate sublist.
In[3]:=
|
Out[3]=
|
In[4]:=
|
Out[4]=
|
Here is a x matrix.
In[5]:=
|
Out[5]=
|
This replaces all the elements of the second row and the first element of the third row by zeros.
In[6]:=
|
Out[6]=
|
In[7]:=
|
|