Wolfram Function Repository
Instant-use add-on functions for the Wolfram Language
Function Repository Resource:
Print all expressions used in the evaluation of an expression, along with the results of evaluating those expressions
ResourceFunction["TracePrintEvaluations"][expr, form] prints an in/out toggler for expressions that match form. | |
ResourceFunction["TracePrintEvaluations"][expr,s] includes all evaluations that use transformation rules associated with the symbol s. |
"Timing" | set to True to include timing of the traced evaluation |
"TraceIn" | function to apply to the traced input |
"TraceOut" | function to apply to the traced input/output pair |
Recursive Fibonacci definition:
In[1]:= |
Use TracePrintEvaluations to track calls to f. Click the printed values to toggle between inputs and outputs:
In[2]:= |
Out[2]= |
See what DateList evaluated to during the following function:
In[3]:= |
The TracePrintEvaluations trace cell includes the evaluation of the subexpression:
In[4]:= |
Out[4]= |
Using SaveDefinitions→True stores all of the evaluation expression in the result cell. Consider the recursive Fibonacci definition again:
In[5]:= |
Using TracePrintEvaluations:
In[6]:= |
Out[6]= |
Notice the CellDingbat of the previous result includes a • character. This indicates that the trace cell evaluation information is stored in the result cell:
In[7]:= |
Out[9]= |
Using the "Timing"→True option includes evaluation timing information in each trace cell:
In[10]:= |
Out[10]= |
Click on any trace cell twice to see the evaluation timing.
Using the "TraceIn"→func option evaluates func[subexpr], where subexpr is the subexpression matching the TracePrintEvaluations pattern, and include the result in the trace cell:
In[11]:= |
Out[11]= |
Click any trace cell twice to see the length of the Plus expression.
The option "TraceIndent"→string specifies the indentation to use to reflect the trace level:
In[12]:= |
Out[12]= |
Using the "TraceOut"→func option evaluates func[subexpr,eval], where subexpr is the subexpression matching the TracePrintEvaluations pattern and eval is what the subexpression evaluated to, and include the result in the trace cell:
In[13]:= |
Out[13]= |
Click any trace cell twice to see a rule indicating what each subexpression evaluated to.
This work is licensed under a Creative Commons Attribution 4.0 International License