Five List Processing Packages

There are five library files that are specifically concerned with list processing. They are


library(basics)
contains very basic list processing operations.
library(lists)
contains operations that view lists as sequences.
library(sets)
contains operations that view lists as sets.
library(ordsets)
contains operations that view lists as sets, but require that the elements of the lists be in standard order (see compare/3 in the reference pages) so as to be much more efficient than library(sets) for any but the smallest sets.
library(listparts)
establishes a common vocabulary for names of parts of lists.

As a general rule, if a predicate defined here has a counter (a non-negative integer) as one of its arguments, it will suffice for the counter argument to be instantiated. Otherwise, at least one of the list arguments must be a proper list. Failing this, the predicate may backtrack forever trying ever longer lists. When you look at the code you will see that some of the library routines use same_length/2 or same_length/3 to ensure termination.