lhs:>rhs or lhsrhs

represents a rule that transforms lhs to rhs, evaluating rhs only after the rule is used.



open allclose all

Basic Examples  (1)

:> holds its right-hand side unevaluated:

The right-hand side is evaluated separately each time it is used:

Applications  (3)

Increment n each time x is replaced:

Evaluate the StepMonitor expression separately each time it is to be used:

Generate a diagonal matrix with random elements:

Properties & Relations  (6)

-> 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 y:

By evaluating the arguments to RuleDelayed, local scoping is avoided:

KeyValuePattern can be used to transform a list of rules:

KeyValuePattern distinguishes between Rule and RuleDelayed:

Introduced in 1988
Updated in 1996