|
ReplacePart
ReplacePart[expr, new, n]は,exprの第n部分をnewで置き換えた式を作成する.
ReplacePart[expr, new, i, j, ... ]は,位置 i, j, ... にある部分を置き換える.
ReplacePart[expr, new,   , , ... ,  , , ... , ... ]は,複数の位置にある部分をnewで置き換える.
ReplacePart[expr, new, pos, npos]は,式exprのposの位置にある部分を式 newの nposの位置にある部分に置き換える.
例:ReplacePart[ a, b, c, d , x, 3]  .
ReplacePartによって使われる位置のリストは,関数Positionによって返されるものと同じ形式を取る.
ReplacePart[expr, Hold[new], pos, 1]は評価をせずに一部分を置換するのに使うことができる.
posとnposの両方が複数の部分を指定する場合,それぞれのposはnpos内の対応する部分で置換される.
ReplacePartはSparseArrayオブジェクトに使うことができる.
参照セクション:1.8.6, 2.1.4, 2.1.4 , 2.4.2.
次も参照:Part,Extract,MapAt,FlattenAt,Insert,Delete,Sequence,StringReplacePart.
バージョン2の新関数.バージョン3で大幅改訂
他の例
|