lists.pl -- List Manipulation
This library provides commonly accepted basic predicates for list manipulation in the Prolog community. Some additional list manipulations are built-in. See e.g., memberchk/2, length/2.
The implementation of this library is copied from many places. These include: "The Craft of Prolog", the DEC-10 Prolog library (LISTRO.PL) and the YAP lists library. Some predicates are reimplemented based on their specification by Quintus and SICStus.
- member(?Elem, ?List)
- True if Elem is a member of List. The SWI-Prolog definition
differs from the classical one. Our definition avoids unpacking
each list element twice and provides determinism on the last
element. E.g. this is deterministic:
member(X, [One]).
Undocumented predicates
The following predicates are exported, but not or incorrectly documented.
- sum_list(Arg1, Arg2)
- permutation(Arg1, Arg2)
- last(Arg1, Arg2)
- nth0(Arg1, Arg2, Arg3)
- selectchk(Arg1, Arg2, Arg3)
- append(Arg1, Arg2)
- subset(Arg1, Arg2)
- is_set(Arg1)
- min_member(Arg1, Arg2)
- reverse(Arg1, Arg2)
- nth1(Arg1, Arg2, Arg3, Arg4)
- delete(Arg1, Arg2, Arg3)
- select(Arg1, Arg2, Arg3, Arg4)
- append(Arg1, Arg2, Arg3)
- union(Arg1, Arg2, Arg3)
- numlist(Arg1, Arg2, Arg3)
- min_list(Arg1, Arg2)
- max_member(Arg1, Arg2)
- same_length(Arg1, Arg2)
- nth0(Arg1, Arg2, Arg3, Arg4)
- prefix(Arg1, Arg2)
- selectchk(Arg1, Arg2, Arg3, Arg4)
- intersection(Arg1, Arg2, Arg3)
- max_list(Arg1, Arg2)
- flatten(Arg1, Arg2)
- proper_length(Arg1, Arg2)
- nth1(Arg1, Arg2, Arg3)
- nextto(Arg1, Arg2, Arg3)
- select(Arg1, Arg2, Arg3)
- subtract(Arg1, Arg2, Arg3)
- list_to_set(Arg1, Arg2)