Wolfram Function Repository
Instant-use add-on functions for the Wolfram Language
Function Repository Resource:
Replace the part of an expression specified by position via a rule
ResourceFunction["ReplacePartWith"][expr,rule,pos] applies a replacement rule to the part of expr at position pos. |
Replace parts 1, 3 and 4 with the rule c→e:
In[1]:= |
Out[1]= |
ReplacePartWith takes lists of positions in the same form as generated by Position:
In[2]:= |
Out[2]= |
In[3]:= |
Out[3]= |
ReplacePart replaces parts of an expression. Exactly what the part is replaced with is specified in advance:
In[4]:= |
Out[4]= |
ReplacePartWith replaces parts of an expression, and what is replaced is determined by the applied rule:
In[5]:= |
Out[5]= |
Replacing an empty list of positions does not change the expression:
In[6]:= |
Out[6]= |
Position {} corresponds to the whole expression:
In[7]:= |
Out[7]= |
This work is licensed under a Creative Commons Attribution 4.0 International License