Wolfram Research

Function Repository Resource:

EchoEvaluate

Source Notebook

Debug application of a function by printing its arguments and the result

Contributed by: Taliesin Beynon

ResourceFunction["EchoEvaluate"][f][args…]

yields the same result as f[args], but prints args and the final result.

Examples

Basic Examples

Define a function and apply its echoed version:

In[1]:=
square[x_] := x^2
In[2]:=
ResourceFunction["EchoEvaluate"][square][2]
Out[2]=

Scope

Use an echoed function defined as a symbol:

In[3]:=
f[x_, ___] := x
In[4]:=
ResourceFunction["EchoEvaluate"][f][1, 2]
Out[4]=

Echo and evaluate a pure function:

In[5]:=
ResourceFunction["EchoEvaluate"][#^2 &][2]
Out[5]=

Requirements

Wolfram Language 11.3 (March 2018) or above

Resource History

License Information