Lookup Function Example

Details

Action

Lookup is designed to work with Association lists. An Association List is a list of lists of the form:

Value [ AList ] = ( (key1 ,...) (key2, ...) ... (keyn, ...) )

The first item in each sublist is a key, an expression. The remaining item(s) in each sublist are the objects to be associated with the key. If you are interested in looking up the items associated at any time with a key, you may call:

Lookup ( key, Alist )

then if value[key] is one of the key1, key2, ..., keyn, the entire associated sublist is returned, otherwise the empty list is returned.

Make Alist list ( list(a,1) , list (b,2), list(c,3) );

Make result lookup( b, Alist);

The value of result is now: ( b 2)

Make result lookup( g, Alist);

The value of result is now the empty list, or value[False]