table digest smart once ...

Prev Next

Function Names

table digest smart once, table digest smart once ignore case

Description

This function works very similarly like table digest 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)) ).

Function 'table digest once'

Call as: procedure or function

Restrictions

Indirect parameter passing is disabled

Parameter count

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

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 } );

       count[] = table digest smart once ignore case
                        ( target,   Seating, Place to go, lookup, Ambience, Restaurant Name, append with comma, true, {Counter,Counter} );

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

       echo("Note: Nothing found for balcony.");
       echo("Target table after lookup (", count[], " items found):");
       table list( target );

Output

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      

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

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

See also

table lookup
table integrate once