lhs=rhs evaluates rhs and assigns the result to be the value of lhs. From then on, lhs is replaced by rhs whenever it appears. {l1, l2, ...}={r1, r2, ...} evaluates the ri, and assigns the results to be the values of the corresponding li.
Set a value for x: In[1]:=x=a + b Out[1]=a + b In[2]:=1 + x^2 Out[2]=1 + (a + b)^2 Unset x: In[3]:=x=. Set multiple values: In[1]:={x, y, z}=Range[3] Out[1]={1, 2, 3} In[2]:=x + y^2 + z^3 Out[2]=32
=
Set is a function that evaluates and assigns an expression to be the value of a variable. The expression Set[lhs, rhs] is commonly represented using the shorthand syntax lhs=rhs. After Set is evaluated, lhs is replaced by rhs whenever it appears. Depending on the form of lhs, the result is stored as in the associated OwnValues, DownValues, or a specialized data structure.
Function | SetDelayed | TagSet | TagSetDelayed | TagUnset | Unset | UpSet | UpSetDelayed
⋮ expr_1|expr_2 | VerticalSeparator[expr_1, expr_2] expr_1∵expr_2 | Because[expr_1, expr_2] expr_1∴expr_2 | Therefore[expr_1, expr_2] expr=. | Unset[expr] expr_1=expr_2 | Set[expr_1, expr_2] expr_1^=expr_2 | UpSet[expr_1, expr_2] expr_1:=expr_2 | SetDelayed[expr_1, expr_2] expr_1^:=expr_2 | UpSetDelayed[expr_1, expr_2] expr_1 function expr_2 | Function[{expr_1}, expr_2] symb/;expr=. | TagUnset[symb, expr] symb/:expr_1=expr_2 | TagSet[symb, expr_1, expr_2] symb/:expr_1:=expr_2 | TagSetDelayed[symb, expr_1, expr_2] expr>>filename | Put[expr, "filename"] expr>>>filename | PutAppend[expr, "filename"] expr_1;expr_2; | CompoundExpression[expr_1, expr_2, Null] expr_1;expr_2;expr_3 | CompoundExpression[expr_1, expr_2, expr_3] ⋮
(grouped in order of decreasing precedence)
HoldFirst | Protected | SequenceHold
SetDelayed | TagSet | UpSet | Increment | Decrement | AddTo | TimesBy | Unset | Clear | HoldPattern | OwnValues | Replace | Dynamic | Setter
5th most common (1 in 34 symbols)
6th most common (1 in 27 symbols)
5th most common (1 in 38 symbols)
introduced in Version 1 (June 1988)