Wolfram Function Repository
Instant-use add-on functions for the Wolfram Language
Function Repository Resource:
Transform an expression by replacing all symbols in one context with symbols of the same name in another context
ResourceFunction["ReplaceContext"][expr,"context1`"→"context2`"] gives expr with all symbols from "context1`" replaced with symbols in "context2`". | |
ResourceFunction["ReplaceContext"][expr,rules] replaces the context with the list of rules. | |
ResourceFunction["ReplaceContext"][rules] represents an operator form of ResourceFunction["ReplaceContext"] that can be applied to an expression. |
Retrieve the ResourceFunction:
In[1]:= |
Out[1]= |
Replace symbols in the current context with symbols in a new context:
In[2]:= |
Out[2]= |
Use a list of replacement rules:
In[3]:= |
Out[3]= |
Use the operator form of ReplaceContext:
In[4]:= |
Out[4]= |
In[5]:= |
Out[5]= |
Copy a definition to a different context:
In[6]:= |
In[7]:= |
Out[7]= |
Now code can be run in the new context without modifying definitions in the current context:
In[8]:= |
Out[8]= |
In[9]:= |
Out[9]= |
In[10]:= |
Out[10]= |
Wolfram Language 11.3 (March 2018) or above
This work is licensed under a Creative Commons Attribution 4.0 International License