WolframLang: Global Variable

By Xah Lee. Date: . Last updated: .
Set[x, y]
(short syntax: x=y)
  • Eval right-hand-side and assign it to left-hand-side.
  • Effectively, this is how you create a global variable.
  • Technically, Set creates a syntax transformation rule. When the pattern on left-hand-side occur, replace it by right-hand-side. [see Set and SetDelayed]
Set
(* global variable, of current session  *)
x = 2
Clear
Clear the value of Symbols. Clear
Clear[x]

(* clear multiple variables *)
Clear[x1,x2]

(* clear all variable starting with x *)
Clear["x*"]
Remove
Remove Symbols from the system. Note: this is more advanced. Usually you just need Clear. Remove

WolframLang: Global Variable

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