Rules

Everything that Mathematica does can be thought of as derived from its ability to apply general transformation rules to arbitrary symbolic expressions. The Mathematica language provides flexible functions that give direct access to Mathematica's powerful rule transformation engine.

ReferenceReference

Representing Rules

Rule (->) immediate replacement rule for any pattern

RuleDelayed (:>) delayed rule, with right-hand side evaluated only when used

Applying Rules

ReplaceAll (/.) apply replacement rules throughout an expression

ReplaceRepeated (//.) apply replacement rules repeatedly until no change occurs

Replace apply replacement rules to a complete expression

ReplaceList a list of all possible ways to apply rules

SparseArray give rules for values at particular positions in an array

New to Mathematica? Find your learning path »
Have a question? Ask support »