This is documentation for Mathematica 5, which was
based on an earlier version of the Wolfram Language.
View current documentation (Version 11.2)

Documentation / Mathematica / Built-in Functions / Programming / Rule Application /

Dispatch

FilledSmallSquare Dispatch[->, ->, ... ] 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 /. rules.

FilledSmallSquare The use of Dispatch will never affect results that are obtained, but may make the application of long lists of rules much faster.

FilledSmallSquare Lists of rules are usually scanned sequentially when you evaluate an expression like expr /. rules. Rules such as a[1]->a1 and a[2]->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.

FilledSmallSquare Lists of rules produced by assignments made with = and := are automatically optimized with dispatch tables when appropriate.

FilledSmallSquare See Section 2.5.2.

FilledSmallSquare See also: ReplaceAll, Compile.

FilledSmallSquare New in Version 2.

Further Examples