protocol
listp
ï
List protocol.
logtalk_load(types(loader))
static
Public predicatesï
append/2
ï
Appends all lists in a list of lists.
static
append(Lists,Concatenation)
append(+list(list),?list)
- zero_or_one
append/3
ï
Appends two lists.
static
append(List1,List2,List)
append(?list,?list,?list)
- zero_or_more
delete/3
ï
Deletes from a list all occurrences of an element returning the list of remaining elements. Uses ==/2
for element comparison.
static
delete(List,Element,Remaining)
delete(@list,@term,?list)
- one
delete_matches/3
ï
Deletes all matching elements from a list, returning the list of remaining elements. Uses =/2
for element comparison.
static
delete_matches(List,Element,Remaining)
delete_matches(@list,@term,?list)
- one
empty/1
ï
True if the argument is an empty list.
static
empty(List)
empty(@list)
- zero_or_one
flatten/2
ï
Flattens a list of lists into a list.
static
flatten(List,Flatted)
flatten(+list,-list)
- one
hamming_distance/3
ï
Calculates the Hamming distance between two lists (using equality to compare list elements). Fails if the two lists are not of the same length.
static
hamming_distance(List1,List2,Distance)
hamming_distance(+list,+list,-integer)
- zero_or_one
keysort/2
ï
Sorts a list of key-value pairs in ascending order.
static
keysort(List,Sorted)
keysort(+list(pair),-list(pair))
- one
last/2
ï
List last element (if it exists).
static
last(List,Last)
last(?list,?term)
- zero_or_more
length/2
ï
List length.
static
length(List,Length)
length(?list,?integer)
- zero_or_more
max/2
ï
Determines the list maximum value using standard order. Fails if the list is empty.
static
max(List,Maximum)
max(+list,-term)
- zero_or_one
member/2
ï
Element is a list member.
static
member(Element,List)
member(?term,?list)
- zero_or_more
memberchk/2
ï
Checks if a term is a member of a list.
static
memberchk(Element,List)
memberchk(?term,?list)
- zero_or_one
min/2
ï
Determines the minimum value in a list using standard order. Fails if the list is empty.
static
min(List,Minimum)
min(+list,-term)
- zero_or_one
msort/2
ï
Sorts a list in ascending order (duplicated elements are not removed).
static
msort(List,Sorted)
msort(+list,-list)
- one
msort/3
ï
Sorts a list using a user-specified comparison predicate modeled on the standard compare/3
predicate (duplicated elements are not removed).
static
msort(Closure,List,Sorted)
msort(3,*,*)
msort(+callable,+list,-list)
- one
nextto/3
ï
X
and Y
are consecutive elements in List.
static
nextto(X,Y,List)
nextto(?term,?term,?list)
- zero_or_more
nth0/3
ï
Nth element of a list (counting from zero).
static
nth0(Nth,List,Element)
nth0(?integer,?list,?term)
- zero_or_more
nth0/4
ï
Nth element of a list (counting from zero). Rest
is a list of all the other elements. Can be used to either select the nth element of List
or to insert an element before the nth element in Rest
.
static
nth0(Nth,List,Element,Rest)
nth0(?integer,?list,?term,?list)
- zero_or_more
nth1/3
ï
Nth element of a list (counting from one).
static
nth1(Nth,List,Element)
nth1(?integer,?list,?term)
- zero_or_more
nth1/4
ï
Nth element of a list (counting from one). Rest
is a list of all the other elements. Can be used to either select the nth element of List
or to insert an element before the nth element in Rest
.
static
nth1(Nth,List,Element,Rest)
nth1(?integer,?list,?term,?list)
- zero_or_more
sequential_occurrences/2
ï
Counts the number of sequential occurrences of each List
element, unifying Occurrences
with a list of Element-Count
pairs. Uses term equality for element comparison.
static
sequential_occurrences(List,Occurrences)
sequential_occurrences(@list,-list(pair(term,positive_integer)))
- one
sequential_occurrences/3
ï
Counts the number of sequential occurrences of each List
element, unifying Occurrences
with a list of Element-Count
pairs. Uses Closure
for element comparison.
static
sequential_occurrences(List,Closure,Occurrences)
sequential_occurrences(@list,@callable,-list(pair(term,positive_integer)))
- one
occurrences/2
ï
Counts the number of occurrences of each List
element, unifying Occurrences
with a sorted list of Element-Count
pairs. Uses term equality for element comparison.
static
occurrences(List,Occurrences)
occurrences(@list,-list(pair(term,positive_integer)))
- one
occurrences/3
ï
Counts the number of occurrences of each List
element, unifying Occurrences
with a sorted list of Element-Count
pairs. Uses Closure
for element comparison.
static
occurrences(List,Closure,Occurrences)
occurrences(*,2,*)
occurrences(@list,@callable,-list(pair(term,positive_integer)))
- one
partition/5
ï
Partitions a list in lists with values less, equal, and greater than a given value (using standard order).
static
partition(List,Value,Less,Equal,Greater)
partition(+list,+number,-list,-list,-list)
- one
permutation/2
ï
The two lists are a permutation of the same list.
static
permutation(List,Permutation)
permutation(?list,?list)
- zero_or_more
prefix/2
ï
Prefix
is a prefix of List
.
static
prefix(Prefix,List)
prefix(?list,+list)
- zero_or_more
prefix/3
ï
Prefix
is a prefix of length Length
of List
.
static
prefix(Prefix,Length,List)
prefix(?list,+integer,+list)
- zero_or_one
prefix(?list,-integer,+list)
- zero_or_more
proper_prefix/2
ï
Prefix
is a proper prefix of List
.
static
proper_prefix(Prefix,List)
proper_prefix(?list,+list)
- zero_or_more
proper_prefix/3
ï
Prefix
is a proper prefix of length Length
of List
.
static
proper_prefix(Prefix,Length,List)
proper_prefix(?list,+integer,+list)
- zero_or_one
proper_prefix(?list,-integer,+list)
- zero_or_more
remove_duplicates/2
ï
Removes duplicated list elements using equality (==/2
) for comparison and keeping the left-most element when repeated.
static
remove_duplicates(List,Set)
remove_duplicates(+list,-list)
- one
reverse/2
ï
Reverses a list.
static
reverse(List,Reversed)
reverse(+list,?list)
- zero_or_one
reverse(?list,+list)
- zero_or_one
reverse(-list,-list)
- one_or_more
same_length/2
ï
The two lists have the same length.
static
same_length(List1,List2)
same_length(+list,?list)
- zero_or_one
same_length(?list,+list)
- zero_or_one
same_length(-list,-list)
- one_or_more
same_length/3
ï
The two lists have the same length.
static
same_length(List1,List2,Length)
same_length(+list,?list,?integer)
- zero_or_one
same_length(?list,+list,?integer)
- zero_or_one
same_length(-list,-list,-integer)
- one_or_more
select/3
ï
Selects an element from a list, returning the list of remaining elements.
static
select(Element,List,Remaining)
select(?term,?list,?list)
- zero_or_more
selectchk/3
ï
Checks that an element can be selected from a list, returning the list of remaining elements.
static
selectchk(Element,List,Remaining)
selectchk(?term,?list,?list)
- zero_or_one
select/4
ï
Selects an element from a list, replacing it by a new element and returning the resulting list.
static
select(Old,OldList,New,NewList)
select(?term,?list,?term,?list)
- zero_or_more
selectchk/4
ï
Checks that an element from a list can be replaced by a new element, returning the resulting list.
static
selectchk(Old,OldList,New,NewList)
selectchk(?term,?list,?term,?list)
- zero_or_one
sort/2
ï
Sorts a list in ascending order (duplicated elements are removed).
static
sort(List,Sorted)
sort(+list,-list)
- one
sort/3
ï
Sorts a list using a user-specified comparison predicate modeled on the standard compare/3
predicate (duplicated elements are removed).
static
sort(Closure,List,Sorted)
sort(3,*,*)
sort(+callable,+list,-list)
- one
sort/4
ï
Sorts a list using the given key and order. Uses the standard term comparison operators for the order. The key selects the argument in each element in the list to use for comparisons. A key value of zero uses the whole element for comparisons.
static
sort(Key,Order,List,Sorted)
sort(+non_negative_integer,+atom,+list,-list)
- one
Removing duplicates: Use one of the
@<
or@>
orders.Keeping duplicates: Use one of the
@=<
or@>=
orders.Sorting in ascending order: Use one of the
@<
or@=<
orders.Sorting in descending order: Use one of the
@>
or@>=
orders.
split/4
ï
Splits a list into sublists of a given length. Also returns a list with the remaining elements. Fails if the length is zero or negative.
static
split(List,Length,Sublists,Remaining)
split(+list,+integer,-list(list),-list)
- zero_or_one
sublist/2
ï
The first list is a sublist of the second.
static
sublist(Sublist,List)
sublist(?list,+list)
- zero_or_more
subsequence/3
ï
List
is an interleaving of Subsequence
and Remaining
. Element order is preserved.
static
subsequence(List,Subsequence,Remaining)
subsequence(?list,?list,?list)
- zero_or_more
subsequence/4
ï
Generates subsequences of a given length from a list. Also returns the remaining elements. Element order is preserved.
static
subsequence(List,Length,Subsequence,Remaining)
subsequence(+list,+integer,?list,?list)
- zero_or_more
substitute/4
ï
Substitutes all occurrences of Old
in List
by New
, returning NewList
. Uses term equality for element comparison.
static
substitute(Old,List,New,NewList)
substitute(@term,@list,@term,-list)
- one
subtract/3
ï
Removes all elements in the second list from the first list, returning the list of remaining elements.
static
subtract(List,Elements,Remaining)
subtract(+list,+list,-list)
- one
suffix/2
ï
Suffix is a suffix of List.
static
suffix(Suffix,List)
suffix(?list,+list)
- zero_or_more
suffix/3
ï
Suffix
is a suffix of length Length
of List
.
static
suffix(Suffix,Length,List)
suffix(?list,+integer,+list)
- zero_or_one
suffix(?list,-integer,+list)
- zero_or_more
proper_suffix/2
ï
Suffix
is a proper suffix of List
.
static
proper_suffix(Suffix,List)
proper_suffix(?list,+list)
- zero_or_more
proper_suffix/3
ï
Suffix
is a proper suffix of length Length
of List
.
static
proper_suffix(Suffix,Length,List)
proper_suffix(?list,+integer,+list)
- zero_or_one
proper_suffix(?list,-integer,+list)
- zero_or_more
take/3
ï
Takes the first N
elements of a list. Fails if the list have fewer than N
elements.
static
take(N,List,Elements)
take(+integer,+list,-list)
- zero_or_one
drop/3
ï
Drops the first N
elements of a list. Fails if the list have fewer than N
elements.
static
drop(N,List,Remaining)
drop(+integer,+list,-list)
- zero_or_one
Protected predicatesï
(none)
Private predicatesï
(none)
Operatorsï
(none)
See also