These predicates manipulate lists. They are bootstrapped predicates (i.e.
written in Prolog) and no error cases are tested (for the moment). However,
since they are written in Prolog using other built-in predicates, some
errors can occur due to those built-in predicates.
append(List1, List2, List12) succeeds if the concatenation of the
list List1 and the list List2 is the list List12.
This predicate is re-executable on backtracking (e.g. if List12 is
instantiated and both List1 and List2 are variable).
sort(List1, List2) succeeds if List2 is the
sorted list corresponding to List1 where duplicate elements are
sort0/2 is similar to sort/2 except that duplicate elements
are not merged.
keysort(List1, List2) succeeds if List2 is the
sorted list of List1 according to the keys. The list List1
consists of items of the form Key-Value. These items are sorted
according to the value of Key yielding the List2. Duplicate
keys are not merged. This predicate is stable, i.e. if K-A occurs
before K-B in the input, then K-A will occur before
K-B in the output.
sort/1, sort0/1 and keysort/1 are similar to
sort/2, sort0/2 and keysort/2 but achieve a sort
in-place destructing the original List1 (this in-place assignment is
not undone at backtracking). The sorted list occupies the same memory space
as the original list (saving thus memory consumption).
The time complexity of these sorts is O(NlogN), N being the length of
the list to sort.
These predicates refer to the standard ordering of terms