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. Or, it is like lisp's symbol. [see Emacs Lisp: 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]

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)

Each symbol, are in particular “context” path. This is similar to a file name has a full path including the dir name. WolframLang “context” is similar to the directory path, or like “namespace” in many programing languages.

The GRAVE ACCENT mark ` is used for context separator, similar to the slash for file path.

WolframLang symbol context 2022-06-05 Rnyv7
WolframLang symbol context
Context[symbol]
return the context (a string) of a symbol.

Context

Context[Sin]
(* "System`" *)

Create Symbol Programatically (Convert String to Symbol, Symbol to String)

Symbol["name"]
Create a symbol, if not already exist. Symbol
SymbolName[symbol]
return the symbol name. SymbolName

List Existing Symbols

Names[pattern]
list existing symbols by a String pattern (regex) .
Names
(* list all symbols whose name contains String *)
Names["*String*"]

Remove a symbol

Remove

Clear a Symbol's Value

Check If a Symbol Has Value

ValueQ

WolframLang Syntax

WolframLang in Depth

Basics

Comment, Print

String

Arithmetic

List

Expression, Atom, Head

Boolean

Conditional

Variable

Loop

Data Structure

Function

Pattern Matching

Advanced

Shell Tasks

Misc