Wolfram Research

Function Repository Resource:

SymbolQ

Source Notebook

Check whether an expression is a symbol

Contributed by: Arnoud Buzing

ResourceFunction["SymbolQ"][expr]

gives True if expr is a symbol and False otherwise.

Details and Options

SymbolQ has the attribute HoldAllComplete.

Examples

Basic Examples

Check if the expression is a symbol or not:

In[1]:=
ResourceFunction["SymbolQ"][x]
Out[1]=
In[2]:=
ResourceFunction["SymbolQ"][42]
Out[2]=
In[3]:=
ResourceFunction["SymbolQ"][f[x]]
Out[3]=

SymbolQ does not evaluate its arguments:

In[4]:=
ResourceFunction["SymbolQ"][$CloudBase]
Out[4]=
In[5]:=
ResourceFunction["SymbolQ"][a + a - a]
Out[5]=

Scope

SymbolQ can be used with Select:

In[6]:=
Select[{1, 4.2, f[x], x}, ResourceFunction["SymbolQ"]]
Out[6]=

Resource History

Related Resources

License Information