Mathematica 9 is now available

Documentation / Mathematica / Built-in Functions / Lists and Matrices / List Operations /

ReplacePart

FilledSmallSquare ReplacePart[expr, new, n] yields an expression in which the n part of expr is replaced by new.

FilledSmallSquare ReplacePart[expr, new, i, j, ... ] replaces the part at position i, j, ... .

FilledSmallSquare ReplacePart[expr, new, , , ... , , , ... , ... ] replaces parts at several positions by new.

FilledSmallSquare ReplacePart[expr, new, pos, npos] replaces parts at positions pos in expr by parts at positions npos in new.

FilledSmallSquare Example: ReplacePart[a, b, c, d, x, 3] LongRightArrow.

FilledSmallSquare The list of positions used by ReplacePart is in the same form as is returned by the function Position.

FilledSmallSquare ReplacePart[expr, Hold[new], pos, 1] can be used to replace a part without evaluating it.

FilledSmallSquare If pos and npos both specify multiple parts, each part in pos is replaced by the corresponding part in npos.

FilledSmallSquare ReplacePart can be used on SparseArray objects.

FilledSmallSquare See Section 1.8.6, Section 2.1.4, Section 2.1.4 and Section 2.4.2.

FilledSmallSquare See also: Part, Extract, MapAt, FlattenAt, Insert, Delete, Sequence, StringReplacePart.

FilledSmallSquare New in Version 2; modified in 3.

Further Examples



Any questions about topics on this page? Click here to get an individual response.Buy NowMore Information
THIS IS DOCUMENTATION FOR AN OBSOLETE PRODUCT.
SEE THE DOCUMENTATION CENTER FOR THE LATEST INFORMATION.