Here we reverse a table mapping various foods to food categories.
>
|
|
| (1) |
| (2) |
Notice that in the above output all the foods in the entries of the output table appear in lists. This is to preserve the keys of the original table T in case any of its keys were expression sequences. Because this is not the case in our example, we can use nolist to simplify the output.
>
|
|
| (3) |
Instead of the default combiner function, use a list constructor and sort the resulting entries.
>
|
|
| (4) |
This table shows what ABO blood type a person has given their genetic profile.
>
|
|
| (5) |
>
|
|
| (6) |
We can see by this result that there are multiple genetic combinations that result in type A, but only one which results in type O.
| (7) |
This table maps countries to their capital cities. Because the entries here are distinct, that is, no city appears as the capital of two countries, we can use the distinctentries option when calling tablereverse.
>
|
|
| (9) |
>
|
|
| (10) |
The fact that entries are distinct in the original table means that with the default combiner function, every entry in the output will be a singleton set. We can avoid this using the identity function as combiner.
>
|
|
| (11) |