Definition
Lists are data structures used when the number of elements is unknown.
- Lists are without index.
- Traditionally, only the first (head) and the remaining items (tail) can be viewed
- Lists have dynamic size, and can grow or shrink as needed.
- Items are added (to the end) via appending
Signature
name: list
import: element, boolean
ops:
newList : → list;
first : list → element;
rest : list → list;
insert : list × element → list;
contains : list × element → boolean;
append : list × element → list;
isEmpty : list → boolean;
etc. (more operations can be defined)