compiletable - create lookup table
tablelook - perform table lookup
insertpattern - append to lookup table
|
Calling Sequence
|
|
compiletable([pattern1=entry1, pattern2=entry2, ...])
tablelook(expr, pattree)
insertpattern(pattern=entry, pattree)
|
|
Parameters
|
|
pattern, pattern1, pattern2, ...
|
-
|
pattern to match
|
entry, entry1, entry2, ...
|
-
|
table entry corresponding to a pattern
|
expr
|
-
|
expression to be matched
|
pattree
|
-
|
pattern match tree returned by compiletable or insertpattern
|
|
|
|
|
Description
|
|
•
|
The compiletable([pattern1=entry1, pattern2=entry2, ...]) calling sequence creates an efficient lookup table by merging patterns (with parameters) into a tree that the pattern matcher (tablelook command) can search in logarithmic time. For example, you can create an integration table in which each pattern is an integrand and the corresponding entry its integral.
|
|
Each table entry is of the form pattern=entry. For information on the format, see patmatch.
|
•
|
The tablelook(expr, pattree) calling sequence compares expr to patterns in pattree. If tablelook finds a match, it returns the corresponding entry with parameter values substituted. Otherwise, it returns FAIL.
|
•
|
The insertpattern(pattern=entry, pattree) calling sequence appends pattern=entry to the end of pattree.
|
|
|
Examples
|
|
>
|
|
>
|
|
>
|
|
Now we can use the table:
>
|
|
| (1) |
>
|
|
| (2) |
>
|
|
| (3) |
>
|
|
| (4) |
|
|
Download Help Document
Was this information helpful?