WolframLang: Symbol

By Xah Lee. Date: . Last updated: .

What is a Symbol

A symbol in WolframLang is similar to identifiers (e.g. variable names and function names) in Python, Java, JavaScript and other programing languages. But can be held unevaluated, just as a inert name by itself. It need not have a value, like a string. (it is like lisp's symbol. [see Elisp: Symbol])

Any sequence of letters you type into wolfram lang become symbols.

For example:

xlist = {3, 4, b+1}
(* {3, 4, 1 + b} *)

(* b is a symbol. no value. stand for itself. *)

(* set a value for b *)
b = 99
(* 99 *)

xlist
(* {3, 4, 100} *)
(* b now has value. *)

another example:

xlist = Table[ {a, b}, {a, 1, 3} ]
(* {{1, b}, {2, b}, {3, b}} *)
(* b is a symbol. no value. stand for itself. *)

(* set a value for b *)
b = 99

xlist
(* 
{{1, 99}, {2, 99}, {3, 99}}
b now has value.
*)

WolframLang code is essentially a sequence of symbols and operators, such as , [] () + - * / # & etc. [see WolframLang: Syntax, Operators Cheatsheet]

Some of the symbols, builtin or user-defined, has value. When a symbol has a value, the value automatically replaces the symbol. (or the function's return value replaces it.) This constitutes the heart of WolframLang computational model, a term-rewriting system.

Create Symbol Programatically (Convert String to Symbol)

Symbol[nameStr]

Create a symbol and return it, if not already exist.

Symbol

Convert Symbol to String

SymbolName[symbol]

return the symbol name, as string.

SymbolName

List Existing Symbols

Names[globPatternStr]

List existing symbols. The pattern string can include a asterisk to stand for any char or none.

Names

(* list all symbols whose name contains String *)
Names["*String*"]

Remove a symbol

Clear a Symbol's Value

Check If a Symbol Has Value

WolframLang Syntax