| Chapter 15: Tables |

| 15.15. Varying which table to look at

So far, we have always used fixed table names when referring to tables: for instance in source like "sort the Table of Recent Monarchs in accession order", we refer to the "Table of Recent Monarchs", a definite and explicitly named table.

With a little care, however, we are allowed to have variables which themselves hold the names of tables. This opens up the possibility of more elaborate ways of storing and interconnecting information in table form, but is probably best avoided until it becomes necessary.

For example, suppose we have two different tables with the same basic structure:

> Table 1 - Nifty Opening Plays in US Scrabble

> word | score
> "muzjiks" | 128

> Table 2 - Nifty Opening Plays in UK Scrabble

> word | score
> "quartzy" | 126
> "squeezy" | 126

We could then record which one of these tables to use in a variable:

> The lexicon is a table-name that varies. The lexicon is Table 1.

Note that for this purpose, the kind of value is a special kind called "table-name", not "table". (The word "table" already has too many meanings and we must be careful to avoid ambiguities here.) We could make use of this as follows, for instance:

> To flip tables:
> say "You exchange dictionaries, lexically crossing the Atlantic. ";
> if the lexicon is Table 1, change the lexicon to Table 2;
> otherwise change the lexicon to Table 1;
> choose a random row in the lexicon;
> say "Did you know that according to [the lexicon], [word entry] scores [score entry]?"

which produces text such as

> You exchange dictionaries, lexically crossing the Atlantic. Did you know that according to Table 1 - Nifty Opening Plays in US Scrabble, muzjiks scores 128?

217
| Example Farewell People who respond to conversational gambits, summarize what they said before if asked again, and provide recap of conversation that is past.

Previous | Contents | Next