Author(s): The CLIP Group.
Version: 1.10#7 (2006/4/26, 19:22:13 CEST)
Version of last change: 1.9#318 (2004/2/26, 15:46:54 CET)
This module provides a set of predicates for list processing.
lists
):- use_module(library(lists)).
nonsingle/1
,
append/3
,
reverse/2
,
reverse/3
,
delete/3
,
delete_non_ground/3
,
select/3
,
length/2
,
nth/3
,
add_after/4
,
add_before/4
,
dlist/3
,
list_concat/2
,
list_insert/2
,
insert_last/3
,
contains_ro/2
,
contains1/2
,
nocontainsx/2
,
last/2
,
list_lookup/3
,
list_lookup/4
,
intset_insert/3
,
intset_delete/3
,
intset_in/2
,
intset_sequence/3
,
intersection/3
,
union/3
,
difference/3
,
equal_lists/2
,
list_to_list_of_lists/2
,
powerset/2
,
cross_product/2
.
list1/2
,
sublist/2
,
subordlist/2
.
lists
)
Usage: nonsingle(X)
X
is not a singleton.
Usage: append(Xs, Ys, Zs)
Zs
is Ys
appended to Xs
.
Usage: reverse(Xs, Ys)
Xs
.
Xs
is a list.
(basic_props:list/1
)
Ys
is any term.
(basic_props:term/1
)
Xs
is a list.
(basic_props:list/1
)
Ys
is a list.
(basic_props:list/1
)
Usage: reverse(A, B, C)
A
, and append it with B
.
Usage: delete(L1, E, L2)
L2
is L1
without the ocurrences of E
.
Usage: delete_non_ground(L1, E, L2)
L2
is L1
without the ocurrences of E
. E
can be a nonground term so that all the elements in L1
it unifies with will be deleted
Usage: select(X, Xs, Ys)
Xs
and Ys
have the same elements except for one occurrence of X
.
General properties: length(A, B)
basic_props:native/1
)
Usage 1: length(L, N)
L
.
L
is a list.
(basic_props:list/1
)
N
is a free variable.
(term_typing:var/1
)
L
is a list.
(basic_props:list/1
)
N
is an integer.
(basic_props:int/1
)
Usage 2: length(L, N)
L
of length N
.
L
is a free variable.
(term_typing:var/1
)
N
is an integer.
(basic_props:int/1
)
L
is a list.
(basic_props:list/1
)
N
is an integer.
(basic_props:int/1
)
Usage 3: length(L, N)
L
is of length N
.
L
is a list.
(basic_props:list/1
)
N
is an integer.
(basic_props:int/1
)
L
is a list.
(basic_props:list/1
)
N
is an integer.
(basic_props:int/1
)
nth(N, List, Elem)
N
is the position in List
of Elem
. N
counts from one.
Usage 1: nth(+int, ?list, ?term)
Elem
and the N
th element of List
.
Usage 2: nth(-int, ?list, ?term)
Elem
is in List
. Positions are found in ascending order.
Usage: add_after(+L0, +E0, +E, -L)
E
after element E0
(or at end) to list L0
returning in L
the new list (uses term comparison).
Usage: add_before(+L0, +E0, +E, -L)
Meta-predicate with arguments: list1(?,pred(1))
.
Usage: list1(X, Y)
X
is a list of Y
s of at least one element.
Usage: dlist(List, DList, Tail)
List
is the result of removing Tail
from the end of DList
(makes a difference list from a list).
Usage: list_concat(LL, L)
L
is the concatenation of all the lists in LL
.
LL
is a list of list
s.
(basic_props:list/2
)
L
is a list.
(basic_props:list/1
)
Usage: list_insert(-List, +Term)
Term
to the end of List
if there is no element in List
identical to Term
.
Usage: insert_last(+L0, +E, -L)
E
at end of list L0
returning L
.
Usage:
Usage:
Usage: nocontainsx(L, X)
X
is not identical to any element of L
.
Usage: last(L, X)
X
is the last element of list L
.
Usage: list_lookup(List, Key, Value)
Usage: list_lookup(List, Functor, Key, Value)
Functor
(Key
,Value
) pair in variable ended key-value pair list L
or else add it at the end.
Usage: intset_insert(A, B, Set)
B
in the ordered set of numbers A
.
Usage: intset_delete(A, B, Set)
A
the element B
.
Usage: intset_in(E, Set)
E
is element of Set
Usage: intset_sequence(N, L1, L2)
N
-1, and append it to L1
.
Usage: intersection(+List1, +List2, -List)
List
has the elements which are both in List1
and List2
.
Usage: union(+List1, +List2, -List)
List
has the elements which are in List1
followed by the elements which are in List2
but not in List1
.
Usage: difference(+List1, +List2, -List)
List
has the elements which are in List1
but not in List2
.
Usage: sublist(List1, List2)
List2
contains all the elements of List1
.
List2
is currently a term which is not a free variable.
(term_typing:nonvar/1
)
Usage: subordlist(List1, List2)
List2
contains all the elements of List1
in the same order.
List2
is currently a term which is not a free variable.
(term_typing:nonvar/1
)
Usage: equal_lists(+List1, +List2)
List1
has all the elements of List2
, and vice versa.
Usage: list_to_list_of_lists(+List, -LList)
LList
is the list of one element lists with elements of List
.
Usage: powerset(+List, -LList)
LList
is the powerset of List
, i.e., the list of all lists which have elements of List
. If List
is ordered, LList
and all its elements are ordered.
Usage: cross_product(+LList, -List)
List
is the cartesian product of the lists in LList
, that is, the list of lists formed with one element of each list in LList
, in the same order.
Go to the first, previous, next, last section, table of contents.