Basic Examples
Basic Examples
Replace parts 1, 3, and 4 with the rule :
ce
[{c,b,c,d},ce,{{1},{3},{4}}]
In[]:=
{e,b,e,d}
Out[]=
Properties and Relations
Properties and Relations
ReplacePartWith
Position[{a,b,x,c,d,x,e},x]
In[]:=
{{3},{6}}
Out[]=
[{a,b,x,c,d,x,e},{xyy},{{3},{6}}]
In[]:=
{a,b,yy,c,d,yy,e}
Out[]=
ReplacePart[{c,b,c,d},{1e,2f,3g}]
In[]:=
{e,f,g,d}
Out[]=
ReplacePartWith
[{c,b,c,d},ce,{{1},{3},{4}}]
In[]:=
{e,b,e,d}
Out[]=
Possible Issues
Possible Issues
Replacing an empty list of positions does not change the expression:
[h[a,b],_x,{}]
In[]:=
h[a,b]
Out[]=
Position corresponds to the whole expression:
{}
[h[a,b],_x,{{}}]
In[]:=
x
Out[]=