Wolfram Research

Function Repository Resource:

PrintDefinitionCases

Source Notebook

Find definitions for symbols in a context using a pattern, getting highlighted occurrences of it

Contributed by: Taliesin Beynon (Wolfram Research)

ResourceFunction["PrintDefinitionCases"][context,patt]

finds all definitions of symbols in context that contain patt at any level and prints them, highlighting the occurrences of patt.

Examples

Basic Examples

Get the definition for a simple function:

In[1]:=
f[x_] := x^2;
In[2]:=
ResourceFunction["e2b9c2d3-646e-4ee2-85d1-4fc604af972e"]["Global`", f[_]]

Get definitions for the function fibo:

In[3]:=
fibo[1] = 1;
fibo[2] = 1;
fibo[n_Integer] := fibo[n] = fibo[n - 1] + fibo[n - 2]
In[4]:=
fibo[3]
Out[4]=
In[5]:=
ResourceFunction["e2b9c2d3-646e-4ee2-85d1-4fc604af972e"]["Global`", fibo[_]]
In[6]:=
ResourceFunction["e2b9c2d3-646e-4ee2-85d1-4fc604af972e"]["Global`", f[_]]

Requirements

Wolfram Language 11.3 (March 2018) or above

Resource History

License Information