Skip to content
Victor Mataré edited this page Feb 18, 2020 · 2 revisions

A list is a dynamically sized container for elements of the same type. It can contain any defined type, i.e. primitive types, compounds or other lists. Before it can be used, the list type needs to be defined:

list[TYPE]

List literals

A literal list value needs to be prefixed with the list type name:

list[TYPE][E1, E2, ...]

Example:

list[number] fluent f() {
initially:
   () = list[number][1, 2, 3];
}

List access

LIST_EXPR[INDEX] // Returns the list element at INDEX

Indices are counted from 0.

List manipulation

push_back(LIST_FLUENT, ELEMENT); // Add ELEMENT at end of LIST_EXPR
push_front(LIST_FLUENT, ELEMENT); // Add ELEMENT at front of LIST_EXPR
pop_back(LIST_FLUENT); // Remove last element
pop_front(LIST_FLUENT); // Remove first element
Clone this wiki locally