Function Repository Resource:

SymbolsWithAttribute

Source Notebook

Find and list all symbols with a particular attribute

Contributed by: Lou D'Andria

ResourceFunction["SymbolsWithAttribute"][attr]

gives a list of the names of symbols that have the given attribute.

ResourceFunction["SymbolsWithAttribute"][attr,patt]

gives a list of names matching the string pattern patt.

Details and Options

ResourceFunction["SymbolsWithAttribute"] takes all the same options as Names.
SymbolsWithAttribute[attr] is equivalent to SymbolsWithAttribute[attr, "*"].

Examples

Basic Examples (2) 

List the names of all available symbols that have the HoldFirst attribute:

In[1]:=
ResourceFunction["SymbolsWithAttribute"][HoldFirst]
Out[1]=

List just those symbol names that match the given string pattern:

In[2]:=
ResourceFunction["SymbolsWithAttribute"][HoldFirst, "*To"]
Out[2]=

Options (2) 

List those HoldAll symbols whose name contains "abort" with any capitalization:

In[3]:=
ResourceFunction["SymbolsWithAttribute"][HoldAll, "*abort*", IgnoreCase -> True]
Out[3]=

List those Protected symbols whose name is similar to "Solve":

In[4]:=
ResourceFunction["SymbolsWithAttribute"][Protected, "Solve", SpellingCorrection -> True]
Out[4]=

Applications (1) 

List those symbols that are both Flat and Orderless:

In[5]:=
Intersection[ResourceFunction["SymbolsWithAttribute"][Flat], ResourceFunction["SymbolsWithAttribute"][Orderless]]
Out[5]=

Properties and Relations (1) 

Attributes returns all the attributes of a given symbol name:

In[6]:=
RandomChoice[ResourceFunction["SymbolsWithAttribute"][OneIdentity]]
Out[6]=
In[7]:=
Attributes["Union"]
Out[7]=

Neat Examples (1) 

List all the attributes for each symbol name in the result:

In[8]:=
# -> Attributes[#] &  /@ ResourceFunction["SymbolsWithAttribute"][OneIdentity]
Out[8]=

Publisher

Lou D'Andria

Requirements

Wolfram Language 11.3 (March 2018) or above

Version History

  • 1.0.0 – 05 March 2019

Related Resources

License Information