Author(s): The CLIP Group.
Version: 1.11#222 (2004/5/24, 13:8:7 CEST)
Version of last change: 1.11#142 (2003/12/31, 12:29:49 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:
Elem
and the N
th element of List
.
List
is a list.
(basic_props:list/1
)
Elem
is any term.
(basic_props:term/1
)
N
is an integer.
(basic_props:int/1
)
List
is a list.
(basic_props:list/1
)
Elem
is any term.
(basic_props:term/1
)
Usage 2:
Elem
is in List
. Positions are found in ascending order.
List
is a list.
(basic_props:list/1
)
Elem
is any term.
(basic_props:term/1
)
N
is a free variable.
(term_typing:var/1
)
N
is an integer.
(basic_props:int/1
)
List
is a list.
(basic_props:list/1
)
Elem
is any term.
(basic_props:term/1
)
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).
L0
is currently a term which is not a free variable.
(term_typing:nonvar/1
)
E0
is currently a term which is not a free variable.
(term_typing:nonvar/1
)
E
is currently a term which is not a free variable.
(term_typing:nonvar/1
)
L
is a free variable.
(term_typing:var/1
)
Usage: add_before(L0, E0, E, L)
L0
is currently a term which is not a free variable.
(term_typing:nonvar/1
)
E0
is currently a term which is not a free variable.
(term_typing:nonvar/1
)
E
is currently a term which is not a free variable.
(term_typing:nonvar/1
)
L
is a free variable.
(term_typing:var/1
)
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(list(LL,list), list(L))
L
is the concatenation of all the lists in LL
.
Usage: list_insert(List, Term)
Term
to the end of List
if there is no element in List
identical to Term
.
List
is a free variable.
(term_typing:var/1
)
Term
is currently a term which is not a free variable.
(term_typing:nonvar/1
)
Usage: insert_last(L0, E, L)
E
at end of list L0
returning L
.
L0
is currently a term which is not a free variable.
(term_typing:nonvar/1
)
E
is currently a term which is not a free variable.
(term_typing:nonvar/1
)
L
is a free variable.
(term_typing:var/1
)
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
.
List1
is currently a term which is not a free variable.
(term_typing:nonvar/1
)
List2
is currently a term which is not a free variable.
(term_typing:nonvar/1
)
List
is a free variable.
(term_typing:var/1
)
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
.
List1
is currently a term which is not a free variable.
(term_typing:nonvar/1
)
List2
is currently a term which is not a free variable.
(term_typing:nonvar/1
)
List
is a free variable.
(term_typing:var/1
)
Usage: difference(List1, List2, List)
List
has the elements which are in List1
but not in List2
.
List1
is currently a term which is not a free variable.
(term_typing:nonvar/1
)
List2
is currently a term which is not a free variable.
(term_typing:nonvar/1
)
List
is a free variable.
(term_typing:var/1
)
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.
List1
is currently a term which is not a free variable.
(term_typing:nonvar/1
)
List2
is currently a term which is not a free variable.
(term_typing:nonvar/1
)
Usage: list_to_list_of_lists(List, LList)
LList
is the list of one element lists with elements of List
.
List
is currently a term which is not a free variable.
(term_typing:nonvar/1
)
LList
is a free variable.
(term_typing:var/1
)
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.
List
is currently a term which is not a free variable.
(term_typing:nonvar/1
)
LList
is a free variable.
(term_typing:var/1
)
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.
LList
is currently a term which is not a free variable.
(term_typing:nonvar/1
)
List
is a free variable.
(term_typing:var/1
)
Go to the first, previous, next, last section, table of contents.