RuleDelayed
lhs:>rhs or lhsrhs
represents a rule that transforms lhs to rhs, evaluating rhs only after the rule is used.
Details
- The character can be entered as :> or ∖[RuleDelayed].
- RuleDelayed has the attribute HoldRest.
- You can apply rules using Replace.
- The assignment lhs:=rhs specifies that the rule lhs:>rhs should be used whenever it applies.
- You can use Condition to specify when a particular rule applies.
- In StandardForm, RuleDelayed is printed using .
Examples
open allclose allBasic Examples (1)
Applications (3)
Increment n each time x is replaced:
Evaluate the StepMonitor expression separately each time it is to be used:
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:
Text
Wolfram Research (1988), RuleDelayed, Wolfram Language function, https://reference.wolfram.com/language/ref/RuleDelayed.html (updated 1996).
CMS
Wolfram Language. 1988. "RuleDelayed." Wolfram Language & System Documentation Center. Wolfram Research. Last Modified 1996. https://reference.wolfram.com/language/ref/RuleDelayed.html.
APA
Wolfram Language. (1988). RuleDelayed. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/RuleDelayed.html