This is documentation for Mathematica 8, which was
based on an earlier version of the Wolfram Language.
View current documentation (Version 11.2)
Assignments
Mathematica's symbolic architecture supports a highly generalized notion of assignment, in which you can specify a transformation for any class of expressions defined by a Mathematica pattern. Simple cases correspond to assignments for "variables", "indexed variables" or "structure elements". Other cases define functions or general transformations.
x=v assign a value (Set)
{x,y}={u,v} assign multiple values
{x,y}={y,x} swap values
    
a[[i]]=v assign a value to a list/array/expression element
    
x++ (Increment ▪ ++x (PreIncrement ▪ x+=y (AddTo)
x-- (Decrement ▪ --x (PreDecrement ▪ x-=y (SubtractFrom)
x*=y (TimesBy ▪ x/=y (DivideBy)
AppendTo, PrependTo add elements to a list
    
Function Definitions
f[x_]:=body define a function
    
Forms of Assignment
lhs=rhs immediate assignment, with rhs evaluated at the time of assignment
lhs:=rhs delayed assignment, with rhs reevaluated every time it is used
    
f/:lhs=rhs, f/:lhs:=rhs associate assignments with the head f
lhs^=rhs, lhs^:=rhs define "upvalues" associated with the leading head in lhs
    
Clearing Assignments
x=. unset the value of x (Unset)
Clear clear all values associated with a symbol
    
Information about Assignments
?x (Information) — get information about all assignments for x
DownValues  ▪ UpValues  ▪ Save
TUTORIALS
MORE ABOUT