Did you know ... Search Documentation:
Pack wam_common_lisp -- prolog/wam_cl/compat/utils_list.pl
PublicShow source

Re-exported predicates

The following predicates are exported from this file while their implementation is defined in imported modules or non-module files loaded by this module.

 sumlist(+List, -Sum) is det
True when Sum is the list of all numbers in List.
- Use sum_list/2
 select(?X, ?XList, ?Y, ?YList) is nondet
Select from two lists at the same position. True if XList is unifiable with YList apart a single element at the same position that is unified with X in XList and with Y in YList. A typical use for this predicate is to replace an element, as shown in the example below. All possible substitutions are performed on backtracking.
?- select(b, [a,b,c,b], 2, X).
X = [a, 2, c, b] ;
X = [a, b, c, 2] ;
See also
- selectchk/4 provides a semidet version.
 nextto(?X, ?Y, ?List)
True if Y directly follows X in List.
 delete(+List1, @Elem, -List2) is det
Delete matching elements from a list. True when List2 is a list with all elements from List1 except for those that unify with Elem. Matching Elem with elements of List1 is uses \+ Elem \= H, which implies that Elem is not changed.
See also
- select/3, subtract/3.
- There are too many ways in which one might want to delete elements from a list to justify the name. Think of matching (= vs. ==), delete first/all, be deterministic or not.
 nth0(?Index, ?List, ?Elem)
True when Elem is the Index'th element of List. Counting starts at 0.
- type_error(integer, Index) if Index is not an integer or unbound.
See also
- nth1/3.
 nth1(?Index, ?List, ?Elem)
Is true when Elem is the Index'th element of List. Counting starts at 1.
See also
- nth0/3.
 nth0(?N, ?List, ?Elem, ?Rest) is det
Select/insert element at index. True when Elem is the N'th (0-based) element of List and Rest is the remainder (as in by select/3) of List. For example:
?- nth0(I, [a,b,c], E, R).
I = 0, E = a, R = [b, c] ;
I = 1, E = b, R = [a, c] ;
I = 2, E = c, R = [a, b] ;
?- nth0(1, L, a1, [a,b]).
L = [a, a1, b].
 nth1(?N, ?List, ?Elem, ?Rest) is det
As nth0/4, but counting starts at 1.
 last(?List, ?Last)
Succeeds when Last is the last element of List. This predicate is semidet if List is a list and multi if List is a partial list.
- There is no de-facto standard for the argument order of last/2. Be careful when porting code or use append(_, [Last], List) as a portable alternative.
 same_length(?List1, ?List2)
Is true when List1 and List2 are lists with the same number of elements. The predicate is deterministic if at least one of the arguments is a proper list. It is non-deterministic if both arguments are partial lists.
See also
- length/2
 subseq(+List, -SubList, -Complement) is nondet
subseq(-List, +SubList, +Complement) is nondet
Is true when SubList contains a subset of the elements of List in the same order and Complement contains all elements of List not in SubList, also in the order they appear in List.
- SICStus. The SWI-Prolog version raises an error for less instantiated modes as these do not terminate.
 numlist(+Low, +High, -List) is semidet
List is a list [Low, Low+1, ... High]. Fails if High < Low.
- type_error(integer, Low)
- type_error(integer, High)

Undocumented predicates

The following predicates are exported, but not or incorrectly documented.

 correspond(Arg1, Arg2, Arg3, Arg4)
 removeallL(Arg1, Arg2, Arg3)
 nmember(Arg1, Arg2, Arg3)
 nmembers(Arg1, Arg2, Arg3)
 perm(Arg1, Arg2)
 perm2(Arg1, Arg2, Arg3, Arg4)
 remove_dups(Arg1, Arg2)
 shorter_list(Arg1, Arg2)
 subseq0(Arg1, Arg2)
 subseq1(Arg1, Arg2)
 zip(Arg1, Arg2, Arg3)
 zip_with(Arg1, Arg2, Arg3, Arg4)