WolframLang: Symbol
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. Or, it is like lisp's symbol. [see ELisp: Symbol]
But WolframLang symbol can be held unevaluated, just as a inert name by itself. It need not have a value.
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.
Context of a Symbol (Namespace)
Create Symbol Programatically (Convert String to Symbol, Symbol to String)
Symbol["name"]
-
Create a symbol, if not already exist.
SymbolName[symbol]
-
return the symbol name.
List Existing Symbols
Names[globPatternStr]
-
List existing symbols. The pattern string can include a asterisk to stand for any char or none.
(* list all symbols whose name contains String *) Names["*String*"]