WolframLang: Rule, RuleDelayed

By Xah Lee. Date: . Last updated: .

A rule in WolframLang is a pair of values. It is used in:

Rule is also used in:

Rule[lhs, rhs]

🔸 SHORT SYNTAX: lhs -> rhs

A pair of values, with left-hand-side lhs and right-hand-side rhs

Both lhs and rhs is evaluated at the time the rule is defined.

Rule

ReplaceAll[ {1, {2}, 3} , {x_} -> x+1]
(* {1, 3, 3} *)
RuleDelayed[lhs, rhs]

🔸 SHORT SYNTAX: lhs :> rhs

Same as Rule, but rhs is evaluated at the time the transformation happens.

RuleDelayed

Pattern Matching