Wolfram Research

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]

gets 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

See the symbols used by a ResourceFunction:

In[1]:=
ResourceFunction["ResourceFunctionSymbols"][
ResourceFunction[
ResourceObject[
Association[
   "Name" -> "GrayCode", "UUID" -> "392603a7-1e9d-46d3-8532-bf09565c732a", "ResourceType" -> "Function", "Version" -> "1.0.0", "Description" -> "Find the Gray code for an integer", "RepositoryLocation" -> URL[
     "https://www.wolframcloud.com/objects/resourcesystem/api/1.0"], "WolframLanguageVersionRequired" -> "10.0", "SymbolName" -> "FunctionRepository`$\
f2402e26e61b4c54b73496fc57b6504d`GrayCode", "FunctionLocation" -> CloudObject[
     "https://www.wolframcloud.com/objects/0050708c-82d0-490c-b9a9-\
2c5e6b23a00b"], "ShortName" -> "GrayCode"], {
   ResourceSystemBase -> Automatic}]]]
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

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

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

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

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]=

Requirements

Wolfram Language 11.3 (March 2018) or above

Resource History

See Also

License Information