Function Repository Resource:

ResourceFunctionSymbols

Source Notebook

Get a list of the symbols used in the definition of a resource function

Contributed by: Richard Hennigan (Wolfram Research)

ResourceFunction["ResourceFunctionSymbols"][rf]

get a list of the symbols used in the definition of the ResourceFunction rf.

Details and Options

ResourceFunction["ResourceFunctionSymbols"] returns a list of fully qualified symbol names as strings.
By default, symbols that are local to the resource are not included in the output.
To include symbols local to the resource, use the option setting "IncludeResourceContext"True.

Examples

Basic Examples (3) 

See the symbols used by a ResourceFunction:

In[1]:=
ResourceFunction["ResourceFunctionSymbols"][
ResourceFunction["GrayCode"]]
Out[1]=
In[2]:=
ResourceFunction["ResourceFunctionSymbols"][
 DefineResourceFunction[# + 1 &, "AddOne"]]
Out[2]=

Use the name of the resource:

In[3]:=
ResourceFunction["ResourceFunctionSymbols"]["ColorToHex"]
Out[3]=

Use a ResourceObject:

In[4]:=
ResourceFunction["ResourceFunctionSymbols"][
 ResourceObject["MoveMouse"]]
Out[4]=

Scope (2) 

See which contexts a resource function explicitly uses:

In[5]:=
Counts[Context /@ ResourceFunction["ResourceFunctionSymbols"]["ExpressionBag"]]
Out[5]=

See which symbols are defined as part of a resource function’s definition:

In[6]:=
Last /@ StringSplit[
  Select[ResourceFunction["ResourceFunctionSymbols"]["ExpressionBag", "IncludeResourceContext" -> True], StringStartsQ["FunctionRepository`"]], "`"]
Out[6]=

Properties and Relations (2) 

ResourceFunctionSymbols works even if the underlying symbol is ReadProtected:

In[7]:=
ResourceFunction["ResourceFunctionSymbols"]["ColorToHex"]
Out[7]=
In[8]:=
FullDefinition[ResourceFunction["ColorToHex"]]
Out[8]=

Compare the list of symbols with the definition:

In[9]:=
ResourceFunction["ResourceFunctionSymbols"]["GrayCode"]
Out[9]=
In[10]:=
ResourceFunction["ResourceFunctionDefinitionViewer"]["GrayCode"]
Out[10]=

Options (2) 

By default, the private symbols used to define the resource are not included:

In[11]:=
ResourceFunction["ResourceFunctionSymbols"]["JoinTo"]
Out[11]=

Include all symbols:

In[12]:=
ResourceFunction["ResourceFunctionSymbols"]["JoinTo", "IncludeResourceContext" -> True]
Out[12]=

Applications (2) 

Use WolframLanguageData to find the minimum possible Wolfram Language version that a resource function’s code should be expected to run on:

In[13]:=
minExpectedWLVersion[id_] :=
      Catch[
           Module[{syms, versions},
                syms = ResourceFunction["ResourceFunctionSymbols"][id];
                If[ FreeQ[syms, s_ /; Context[s] =!= "System`", {1}], versions = WolframLanguageData[Last /@ StringSplit[syms, "`"], "VersionIntroduced"]; Replace[versions, {___, m : Except[_?NumberQ], ___} :> Throw[m, $tag]];
                     Max[versions],
                     Missing["Indeterminate"]
                 ]
            ],
           $tag
       ];
In[14]:=
minExpectedWLVersion["GrayCode"]
Out[14]=
In[15]:=
minExpectedWLVersion["ColorToHex"]
Out[15]=
In[16]:=
minExpectedWLVersion[DefineResourceFunction[# + 1 &, "AddOne"]]
Out[16]=

If symbols from contexts other than System` are used, the version isn’t known:

In[17]:=
minExpectedWLVersion["MoveMouse"]
Out[17]=
In[18]:=
Counts[Context /@ ResourceFunction["ResourceFunctionSymbols"]["MoveMouse"]]
Out[18]=

Version History

  • 2.0.0 – 21 October 2019
  • 1.0.0 – 19 April 2019

Related Resources

License Information