WolframLang: Rule, RuleDelayed

By Xah Lee. Date: . Last updated: .

A rule in WolframLang is a pair of values. It is 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[ {a, b, c} , x_ -> x+1]
=== {1 + a, 1 + b, 1 + c}
RuleDelayed[lhs, rhs]

🔸 SHORT SYNTAX: lhs :> rhs

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

RuleDelayed

Pattern Matching