Wolfram Function Repository
Instant-use add-on functions for the Wolfram Language
Function Repository Resource:
Set the context for all symbols in an expression
ResourceFunction["SetSymbolsContext"][expr] returns expr with all symbols set to the current $Context. | |
ResourceFunction["SetSymbolsContext"][expr,cont] uses cont as a new context instead. |
Set symbols to the current context:
| In[1]:= |
| Out[1]= |
Set symbols to the specified context:
| In[2]:= |
| Out[2]= |
Retrieve nicer looking definitions from package functions:
| In[4]:= |
| In[5]:= |
| Out[5]= | ![]() |
| In[6]:= |
| Out[6]= | ![]() |
SetSymbolsContext is equivalent to ReplaceContext with explicitly constructed replacement rules for all contexts appearing in the expression:
| In[7]:= |
| Out[7]= |
| In[8]:= |
| Out[8]= |
If symbols have definitions in the current context, these definitions are going to be immediately applied on return:
| In[9]:= |
| In[10]:= |
| Out[10]= |
Hold the expression to prevent it:
| In[11]:= |
| Out[11]= |
This work is licensed under a Creative Commons Attribution 4.0 International License