Branching lists

Lists can support set formation to create complex branching structures showing "lists within lists". Why might such behavior be useful?

Suppose I have a t-shirt that is to be worn on the 1st, 3rd, 5th and 8th of the month. But I don't want to be too predictable; the order 1-3-6-7 is also acceptable as is 1-3-6-9 and 2-3-6-9. This means there exist alternative schedules that could be represented diagramatically as

   1----->3----->5----->8
             |
             |
             |
             --->6----->7
                    |
                    |
                    |
                    --->9


   2----->3----->6----->9
The data file would look like this:

TShirt : sam11
Wear_on_days 1 3 5 8
Wear_on_days 1 3 6 7
Wear_on_days 1 3 6 9
Wear_on_days 2 3 6 9
The corresponding text window resembles the diagram:

A REPEATed field can be modified by UNIQUE to forbid branching:

         Wear_on_days UNIQUE Int REPEAT
In this case you can store only one list at a time. Reading in the data above would store only the last list:

If you go back now and re-read the sections on sets you will recognize that sets also produce branching structures. The essential differences between the two are:


Show me the whole t-shirt model again.

Back to Table of Contents