table expand smart once ...

Prev Next

Function Names

table expand smart once, table expand smart once ignore case

Description

This function works very similarly like table expand smart(), with the only difference that every row in the lookup table can be be retrieved only once and will then be internally marked as taken. Further lookups for remaining rows in the target table will skip the lookup table rows already taken. The search time ratio versus table size n is O ( log(n)) ).

Call as: procedure or function

Restrictions

Indirect parameter passing is disabled

Parameter count

6 - 8 (For parameter description and return values: see table expand() )

Examples

       table load( lookup, "Examples/Table Lookup Example 2.csv" );
       table delete remaining rows ( lookup, -2 ); // Remove last 2 rows (the mom's place and 'not found' row)

       table initialize( target, { Seating, inside, balcony, outside, bar } );

       echo("Target table before lookup:");
       table list( target );

       count[] = table expand smart once ignore case
                 ( target,   Seating, {Place to go, Table size},
                       lookup, Ambience, {Restaurant Name, Table size}, {}, true, {Counter,Counter} );

       echo("Lookup table:");
       table list( lookup );

       echo("Target table after lookup (", count[], " items found):");
       table list( target );

Output

Target table before lookup:
    0 : Seating
    1 : inside
    2 : balcony
    3 : outside
    4 : bar    

Lookup table:
    0 : Offering           | Table size | Ambience               | Restaurant Name       | Phone Number   | Counter
    1 : *Chicken*          | 2,4,6      | inside,bar             | Rôtisserie de Paris   | (212) 555-1234 | 1      
    2 : *Curry*            | 1..10      | "self-service"         | Bharat take-away      | (212) 555-2345 |        
    3 : *Pizza*,*Pasta*    | 4,6,8      | inside,outside         | Luigis                | (212) 555-3456 | 1      
    4 : *Beer*,*Wine*      | *          | bar                    | Luigis                | (212) 555-3456 | 1      
    5 : *Pizza*,*sea*food* | *          | inside,outside         | All-Italian Trattoria | (212) 555-4567 | 1      
    6 : *Fish*,*sea*food*  | 2..8       | outside                | Wharf Place           | (212) 555-5678 | 1      
    7 : *Burger*,Fries     | 1..20      | =inside,"self-service" | Mr. Burgermeister     | (212) 555-6789 | 1      

Target table after lookup (6 items found):
    0 : Seating | Place to go           | Table size | Counter
    1 : inside  | Rôtisserie de Paris   | 2,4,6      | 1      
    2 : inside  | Luigis                | 4,6,8      | 1      
    3 : inside  | All-Italian Trattoria | *          | 1      
    4 : inside  | Mr. Burgermeister     | 1..20      | 1      
    5 : balcony |                       |            |        
    6 : outside | Wharf Place           | 2..8       | 1      
    7 : bar     | Luigis                | *          | 1      

Try it yourself: Open LIB_Function_table_expand_smart_once.b4p in B4P_Examples.zip. Decompress before use.

See also

table expand
table integrate once