Mathematica 9 is now available
THIS IS DOCUMENTATION FOR AN OBSOLETE PRODUCT.
SEE THE DOCUMENTATION CENTER FOR THE LATEST INFORMATION.
Mathematica > Core Language > Rules & Patterns > Rules > RuleDelayed (:>, ⧴) >

RuleDelayed

or
represents a rule that transforms lhs to rhs, evaluating rhs only after the rule is used.
  • You can apply rules using Replace.
  • The assignment specifies that the rule should be used whenever it applies.
  • You can use Condition to specify when a particular rule applies.
holds its right-hand side unevaluated:
The right-hand side is evaluated separately each time it is used:
holds its right-hand side unevaluated:
In[1]:=
Click for copyable input
Out[1]=
The right-hand side is evaluated separately each time it is used:
In[2]:=
Click for copyable input
Out[2]=
Increment each time is replaced:
Evaluate the StepMonitor expression separately each time it is to be used:
Generate a diagonal matrix with random elements:
evaluates when it is first entered; when it is used:
Module and With do not affect local variables of RuleDelayed:
Module effectively uses a renamed instance of :
By evaluating the arguments to RuleDelayed, local scoping is avoided:
New in 1 | Last modified in 3
Ask a question about this page  |  Suggest an improvement  |  Leave a message for the team
Format:   HTML  |  CDF