] generates an optimized dispatch table representation of a list of rules. The object produced by Dispatch can be used to give the rules in expr
The use of Dispatch will never affect results that are obtained, but may make the application of long lists of rules much faster.
Lists of rules are usually scanned sequentially when you evaluate an expression like expr
rules. Rules such as a->a1 and a->a2, which cannot simultaneously apply, need not both be scanned explicitly. Dispatch generates a dispatch table which uses hash codes to specify which sets of rules need actually be scanned for a particular input expression.
Lists of rules produced by assignments made with = and := are automatically optimized with dispatch tables when appropriate.
See the Mathematica book: Section 2.4.2.
See also: ReplaceAll, Compile.
Here is a list of rules for the first five factorials.
This sets up dispatch tables that make the rules faster to use.
You can apply the rules using the /. operator.
THIS IS DOCUMENTATION FOR AN OBSOLETE PRODUCT.
SEE THE DOCUMENTATION CENTER
FOR THE LATEST INFORMATION.