|
Delayed Rules
The notation -> is the alias for the function Rule. The notation :> is the alias for the function RuleDelayed. The notation x->Random[] specifies a rule to replace x with the evaluated Random[]. The expression Random[] evaluates to a random number. The notation x:>Random[] specifies a rule to replace x with the unevaluated expression Random[].
Delayed rules are like delayed assignments in that the right side of the rule is evaluated after the replacement has been made.
Using Trace, you can see the order in which Mathematica evaluates these expressions. With an immediate assignment, Mathematica first replaces Table with a list of three x's. Then Mathematica calls Random and obtains a value. Then each x in the list is replaced by that value.
With a delayed assignment, Mathematica first replaces Table with a list of three x's. Then Mathematica replaces each x in the list with a call to Random. Then Mathematica evaluates each call to Random.
You can specify rules to transform sums of angles. These rules used to be in the standard package Algebra`Trigonometry`. In Version 3, they were incorporated into the Mathematica kernel.
 Copyright © 2002 Wolfram Media, Inc. All
rights reserved. |