Wolfram Function Repository
Instant-use add-on functions for the Wolfram Language
Function Repository Resource:
Store full definitions for a symbol in a compact object
ResourceFunction["DefinitionData"][symbol] returns a definition object for symbol and all its dependencies. | |
ResourceFunction["DefinitionData"][…][property] returns the definition information specified by property. |
| "Name" | the fully qualified name of the symbol |
| "Definitions" | an Association containing full definition information |
| "Symbols" | a list of all the contained symbols, each wrapped in HoldForm |
| "Names" | a list of fully qualified symbol names |
| "Size" | the full size of the definition data in bytes |
| "Contexts" | a list of all contexts for the defined symbols |
| "DefinitionList" | returns a Language`DefinitionList of the definition data |
Get all needed definitions for f, which depends on the function g:
| In[1]:= |
|
| Out[3]= |
|
View information about the definitions:
| In[4]:= |
|
| Out[4]= |
|
Using Get can restore cleared symbols:
| In[5]:= |
|
| In[6]:= |
|
| Out[6]= |
|
| In[7]:= |
|
| Out[7]= |
|
| In[8]:= |
|
| Out[8]= |
|
Store definitions from a package as an object that can be stored in notebooks:
| In[9]:= |
|
| Out[10]= |
|
View the definitions:
| In[11]:= |
|
| Out[11]= |
|
| In[12]:= |
|
This is now equivalent to loading the original package:
| In[13]:= |
|
| Out[13]= |
|
The definition is loaded:
| In[14]:= |
|
| Out[14]= |
|
| In[15]:= |
|
| Out[15]= |
|
Get a list of available properties:
| In[16]:= |
|
| Out[16]= |
|
See what symbols are contained:
| In[17]:= |
|
| Out[17]= |
|
Use a list of properties to return an Association:
| In[18]:= |
|
| Out[18]= |
|
The InputForm of DefinitionData serializes definitions to protect contexts and initialization states of values:
| In[19]:= |
|
| Out[19]= |
|
Use FullForm to see the actual expression structure:
| In[20]:= |
|
| Out[20]= |
|
When writing DefinitionData to a file as InputForm via Put, CloudPut, Export, etc., original contexts will be preserved in binary form:
| In[21]:= |
|
| Out[12]= |
|
| In[22]:= |
|
Changing $Context or $ContextPath will not affect which contexts the contained symbols are created in:
| In[23]:= |
|
| Out[24]= |
|
Load the definitions:
| In[25]:= |
|
| Out[25]= |
|
The symbols are redefined in their original contexts:
| In[26]:= |
|
| Out[26]= |
|
Some contexts (such as System`) are excluded when including definitions:
| In[27]:= |
|
| Out[12]= |
|
| In[28]:= |
|
| Out[28]= |
|
Wolfram Language 11.3 (March 2018) or above
This work is licensed under a Creative Commons Attribution 4.0 International License