![]() |
  |
|
1.2.8 Automatic rule reordering What is less trivial is that in this example we would get similar behavior even if we defined this rule first:
To see the order in which the rules are kept, we again use DownValues :
We see that the rule with Sine again is at the end, despite having been defined first. The reason is that Mathematica pattern-matching engine has a built-in rule analyzer which sorts the rules such that more general rules come after more specific ones, when it can determine it. This is not always possible to do automatically (and not always possible to unambiguously do at all), so in general the programmer should take care of it. But in practice, it is seldom needed to manipulate the rules by hand.
|
|||||||||||||||||