There are three types of lists in eXPL:
- Value Lists
- Term Lists
- Axiom Lists
Value List items are of a single type, while Term List items are the terms of a backing axiom and therefore can be of mixed types. Axiom lists, described here,
Value Lists
A value list declaration has format: list<type> name. eg.
This is a list of alphabetical scores from "a+" to "f-" which appears in the example below.
A list starts out empty and is populated by assigning items to it. The valid index ranges starts from zero,
but the list can start with any positive number and be populated non-contiguously.1
There are 3 possibilities how to reference a value list:
- use an integer literal eg. mark[0]
- use a variable containing an integer value eg.
mark[english]where "english" is an integer - use an expression which evaluates to an integer value eg. mark[i++]
The variable index is handy as the it's value can be provided by unification. Here is an example where numerical grades are converted to alphabetical marks using unification and a list:
{"Sarah", 12, 17, 15}
{"Amy", 14, 16, 6};
mark[0] = "f-";\
mark[1] = "f";
...
mark[16] = "a";
mark[17] = "a+";
template score(student, mark[english], mark[maths], mark[history]);
query marks(grades : score);
The tutorial6StudentScores code example which runs this query. The solution when the query is run is:
Sarah, mark_english = b-, mark_maths = a+, mark_history = a-
Amy, mark_english = b+, mark_maths = a, mark_history = d-
Term Lists
A Term list wraps an axiom so it can be accessed by array notation. The declaration format: list<term> name(axiom-to-wrap). eg. in the opposite example Term list color wraps axiom swatch
