Wolfram Function Repository
Instant-use add-on functions for the Wolfram Language
Function Repository Resource:
Convert formal symbols in an expression into non-formal versions
ResourceFunction["UnformalizeSymbols"][expr] converts all formal symbols in expr to their non-formal counterparts. |
"DeferQ" | False | whether to wrap replaced symbols in Defer |
"TargetContext" | Automatic | the context to place converted symbols into |
Convert formal symbols to their non-formal counterparts:
In[1]:= |
Out[1]= |
UnformalizeSymbols works on Latin, Greek and other symbols for which there exists a formal version in the Wolfram Language:
In[2]:= |
Out[2]= |
In[3]:= |
Out[3]= |
UnformalizeSymbols works on both uppercase and lowercase letters:
In[4]:= |
Out[4]= |
By default, symbols in the output of UnformalizeSymbols may ultimately evaluate, should they have definitions. Here, a has a value in "Global`" and so does not appear in the final result:
In[5]:= |
Out[5]= |
With the setting "DeferQ"→ True, replaced symbols are wrapped in Defer prior to output, preventing their evaluation until given explicitly as input (using , Evaluate in Place, etc.):
In[6]:= |
Out[6]= |
In[7]:= |
Out[7]= |
By default, replaced symbols in the output of UnformalizeSymbol are in the current context:
In[8]:= |
Out[9]= |
A different context can be specified via the "TargetContext" option:
In[10]:= |
Out[10]= |
This work is licensed under a Creative Commons Attribution 4.0 International License