compiletable
create lookup table
tablelook
perform table lookup
insertpattern
append to lookup table
Calling Sequence
Parameters
Description
Examples
compiletable([pattern1=entry1, pattern2=entry2, ...])
tablelook(expr, pattree)
insertpattern(pattern=entry, pattree)
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
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.
tab≔ln⁡a::radnum⁢_X+b::radnum=ln⁡a⁢x+b⁢x+1a⁢ln⁡a⁢x+b⁢b−x−1a⁢b,exp⁡a::radnum⁢_X=1a⁢exp⁡a⁢x,exp⁡a::radnum⁢_X2+b::radnum=12⁢π12−a12⁢erf⁡−a12⁢x⁢exp⁡b,cos⁡a::radnum⁢_X=1a⁢sin⁡a⁢x,sin⁡a::radnum⁢_X2=12⁢212⁢π12a12⁢FresnelS⁡212π12⁢a12⁢x,sin⁡a::radnum⁢_X=−1a⁢cos⁡a⁢x,_X1+sin⁡_X=−xcos⁡x+x⁢tan⁡x+ln⁡cos⁡x+ln⁡sec⁡x+tan⁡x,_X1−sin⁡_X=xcos⁡x+x⁢tan⁡x+ln⁡cos⁡x−ln⁡sec⁡x+tan⁡x,a::radnum⁢_X+b::radnum=a2⁢x2+b⁢x,_X+a::radnum−1=ln⁡x+a,a::radnum⁢_Xn::integer=an+1⁢xn+1:
tab≔subs⁡_X=x::name,tab:
p≔compiletable⁡tab:
Now we can use the table:
tablelook⁡cos⁡2⁢x,p
sin⁡2⁢x2
tablelook⁡ln⁡2⁢z,p
ln⁡2⁢z⁢z−z
tablelook⁡exp⁡2⁢x2−3,p
−π⁢−2⁢erf⁡−2⁢x⁢ⅇ−34
map⁡tablelook,12⁢x5+3⁢x2−x+1x+2,p
x612+x3−x22+ln⁡x+2
See Also
patmatch
Download Help Document