Question: compiletable, tablelook, insertpattern

For the set of functions
   compiletable - create lookup table
   tablelook - perform table lookup
   insertpattern - append to lookup table

I observe these behaviors:
1. The function tablelook( ) only seems to work when the table has been been intiailized with compiletable( ).
2. The function insertpattern( )  nevers seems to work.

Example#1: Starting with an empty table, insertpattern( ) seems to work, but tablelook( ) can't find the inserted pattern.
> rrt := [];
                                     []
> data := table(rrt);

> rrtc := compiletable(rrt);
                                     []
> i := 45.;
                                     45.
> tablelook(i, rrtc);
                                    false
The tablelook( ) should return FAIL
> insertpattern(45. = 34, rrtc);
                       [/LITER(1, 45.), /PATTERN(34)]
> tablelook(i, rrtc);
                                    false
insertpattern( ) does not find a newly inserted pattern. tablelook should return FAIL, not 'false'
----------------------------------------------
Example #2: 
1. Initialize the table with a do nothing pattern.  This works.
2. Look for a pattern that does not exist in the table.  This works by returning FAIL as it should.
3. Insert a new pattern.  tablelook does not find the pattern and returns FAIL, not 'false' as in Example#1.

> rrt := [date = 20080921];
                              [date = 20080921]
> data := table(rrt);

> data[date];
                                  20080921
> rrtc := compiletable(rrt);
                    [/LITER(1, date), /PATTERN(20080921)]
> tablelook(date, rrtc);
                                  20080921
> i := 45.;
                                     45.
> tablelook(i, rrtc);
                                    FAIL
> insertpattern(45. = 34, rrtc);
/ODER([/LITER(1, date), /PATTERN(20080921)], [/LITER(1, 45.), /PATTERN(34)])
> tablelook(45., rrtc);
                                    FAIL
-------------------------------------------------------------------Example #3.
1. Check to see if 45. is a vaild pattern.  Using compiletable( ), this works.
2. Add a new pattern.  The insertpattern( ) seems to work.
3. tablelook ( ) for the new pattern.  This does not work.  Returns a FAIL, which means the table acts like it was intialized with the compiletable, but does not find the pattern and returns FAIL, not false.

> rrt := [45. = 34];
                                 [45. = 34]
> data := table(rrt);

> data[45.];
                                     34
> rrtc := compiletable(rrt);
                       [/LITER(1, 45.), /PATTERN(34)]
> tablelook(45., rrtc);
                                     34
> insertpattern(44. = 38, rrtc);
    /ODER([/LITER(1, 45.), /PATTERN(34)], [/LITER(1, 44.), /PATTERN(38)])
> tablelook(44., rrtc);
                                    FAIL

-------------------------------------------------------------------------------------------------------------------------------------------------------
Does this mean that I have to compiletable( ) each time I add something, and that insertpattern( ) never works?

Thanks!

Danny Mills

Please Wait...