Wolfram Function Repository
Instant-use add-on functions for the Wolfram Language
Function Repository Resource:
Inherit a symbol's definitions
ResourceFunction["InheritDefinitions"][source,target] make the target symbol inherit all definitions from the source symbol. |
Define a down value for a symbol:
| In[1]:= |
Create a new symbol and inherit all current and consequent definitions:
| In[2]:= |
Create more definitions:
| In[3]:= |
The second symbol has all definition of the first:
| In[4]:= |
| Out[9]= |
Inherit UpValues:
| In[10]:= | ![]() |
| Out[14]= |
Use inherited definition in pattern matching:
| In[15]:= | ![]() |
| Out[21]= |
Inherit OwnValues:
| In[22]:= | ![]() |
| Out[23]= |
Inherit formatting:
| In[24]:= | ![]() |
| Out[25]= |
Inherit Options and Default values:
| In[26]:= | ![]() |
| Out[27]= |
Inherit NValues:
| In[28]:= | ![]() |
| Out[29]= |
Inherit Messages:
| In[30]:= | ![]() |
Only a single definition per type (DownValues, UpValues etc.) is added to the target symbol:
| In[31]:= | ![]() |
| Out[36]= |
The inheriting symbols behaves as if it has the all the DownValues:
| In[37]:= |
| Out[37]= |
Recursive definitions can be inherited:
| In[38]:= | ![]() |
| Out[39]= |
Self-dependencies work no matter how deep they are:
| In[40]:= | ![]() |
| Out[41]= |
Positional Default values doesn't work:
| In[42]:= | ![]() |
| Out[43]= |
| In[44]:= | ![]() |
| Out[45]= |
Attributes are not inherited, therefore setting source attributes wouldn't propagate to a target:
| In[46]:= | ![]() |
| Out[47]= |
| In[48]:= |
| Out[49]= |
Wolfram Language 13.0 (December 2021) or above
This work is licensed under a Creative Commons Attribution 4.0 International License