protocol

# listp

> List protocol.

author:
  `Paulo Moura`
version:
  `1.9`
date:
  `2012/4/25`

compilation flags:
  `static`

(no dependencies on other files)

## Public interface

### append/2

> Appends all lists in a list of lists.

compilation flags:
  `static`
template:
  `append(Lists,Concatenation)`
mode – number of proofs:
  `append(+list(list),?list) – zero_or_one`

### append/3

> Appends two lists.

compilation flags:
  `static`
template:
  `append(List1,List2,List)`
mode – number of proofs:
  `append(?list,?list,?list) – zero_or_more`

### delete/3

> Deletes from a list all occurrences of an element returning the list of remaining elements.

compilation flags:
  `static`
template:
  `delete(List,Element,Remaining)`
mode – number of proofs:
  `delete(@list,@term,?list) – one`

### delete_matches/3

> Deletes all matching elements from a list, returning the list of remaining elements.

compilation flags:
  `static`
template:
  `delete_matches(List,Element,Remaining)`
mode – number of proofs:
  `delete_matches(@list,@term,?list) – one`

### empty/1

> True if the argument is an empty list.

compilation flags:
  `static`
template:
  `empty(List)`
mode – number of proofs:
  `empty(@list) – zero_or_one`

### flatten/2

> Flattens a list of lists into a list.

compilation flags:
  `static`
template:
  `flatten(List,Flatted)`
mode – number of proofs:
  `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.

compilation flags:
  `static`
template:
  `hamming_distance(List1,List2,Distance)`
mode – number of proofs:
  `hamming_distance(+list,+list,-integer) – zero_or_one`

### keysort/2

> Sorts a list of key-value pairs in ascending order.

compilation flags:
  `static`
template:
  `keysort(List,Sorted)`
mode – number of proofs:
  `keysort(+list,-list) – one`

### last/2

> List last element (if it exists).

compilation flags:
  `static`
template:
  `last(List,Last)`
mode – number of proofs:
  `last(?list,?term) – zero_or_more`

### length/2

> List length.

compilation flags:
  `static`
template:
  `length(List,Length)`
mode – number of proofs:
  `length(?list,?integer) – zero_or_more`

### max/2

> Determines the list maximum value using standard order. Fails if the list is empty.

compilation flags:
  `static`
template:
  `max(List,Maximum)`
mode – number of proofs:
  `max(+list,-term) – zero_or_one`

### member/2

> Element is a list member.

compilation flags:
  `static`
template:
  `member(Element,List)`
mode – number of proofs:
  `member(?term,?list) – zero_or_more`

### memberchk/2

> Checks if a term is a member of a list.

compilation flags:
  `static`
template:
  `memberchk(Element,List)`
mode – number of proofs:
  `memberchk(?term,?list) – zero_or_one`

### min/2

> Determines the minimum value in a list using standard order. Fails if the list is empty.

compilation flags:
  `static`
template:
  `min(List,Minimum)`
mode – number of proofs:
  `min(+list,-term) – zero_or_one`

### msort/2

> Sorts a list in ascending order (duplicated elements are not removed).

compilation flags:
  `static`
template:
  `msort(List,Sorted)`
mode – number of proofs:
  `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).

compilation flags:
  `static`
template:
  `msort(Closure,List,Sorted)`
meta-predicate template:
  `msort(3,*,*)`
mode – number of proofs:
  `msort(+callable,+list,-list) – one`

### nextto/3

> X and Y are consecutive elements in List.

compilation flags:
  `static`
template:
  `nextto(X,Y,List)`
mode – number of proofs:
  `nextto(?term,?term,?list) – zero_or_more`

### nth0/3

> Nth element of a list (counting from zero).

compilation flags:
  `static`
template:
  `nth0(Nth,List,Element)`
mode – number of proofs:
  `nth0(?integer,?list,?term) – zero_or_more`

### nth0/4

> Nth element of a list (counting from zero).

compilation flags:
  `static`
template:
  `nth0(Nth,List,Element,Residue)`
mode – number of proofs:
  `nth0(?integer,?list,?term,?list) – zero_or_more`

### nth1/3

> Nth element of a list (counting from one).

compilation flags:
  `static`
template:
  `nth1(Nth,List,Element)`
mode – number of proofs:
  `nth1(?integer,?list,?term) – zero_or_more`

### nth1/4

> Nth element of a list (counting from zero).

compilation flags:
  `static`
template:
  `nth1(Nth,List,Element,Residue)`
mode – number of proofs:
  `nth1(?integer,?list,?term,?list) – zero_or_more`

### partition/5

> Partitions a list in lists with values less, equal, and greater than a given value (using standard order).

compilation flags:
  `static`
template:
  `partition(List,Value,Less,Equal,Greater)`
mode – number of proofs:
  `partition(+list,+number,-list,-list,-list) – one`

### permutation/2

> The two lists are a permutation of the same list.

compilation flags:
  `static`
template:
  `permutation(List,Permutation)`
mode – number of proofs:
  `permutation(?list,?list) – zero_or_more`

### prefix/2

> Prefix is a prefix of List.

compilation flags:
  `static`
template:
  `prefix(Prefix,List)`
mode – number of proofs:
  `prefix(?list,+list) – zero_or_more`

### proper_prefix/2

> Prefix is a proper prefix of List.

compilation flags:
  `static`
template:
  `proper_prefix(Prefix,List)`
mode – number of proofs:
  `proper_prefix(?list,+list) – zero_or_more`

### reverse/2

> Reverses a list.

compilation flags:
  `static`
template:
  `reverse(List,Reversed)`
mode – number of proofs:
  `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.

compilation flags:
  `static`
template:
  `same_length(List1,List2)`
mode – number of proofs:
  `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.

compilation flags:
  `static`
template:
  `same_length(List1,List2,Length)`
mode – number of proofs:
  `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.

compilation flags:
  `static`
template:
  `select(Element,List,Remaining)`
mode – number of proofs:
  `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.

compilation flags:
  `static`
template:
  `selectchk(Element,List,Remaining)`
mode – number of proofs:
  `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.

compilation flags:
  `static`
template:
  `select(Old,OldList,New,NewList)`
mode – number of proofs:
  `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.

compilation flags:
  `static`
template:
  `selectchk(Old,OldList,New,NewList)`
mode – number of proofs:
  `selectchk(?term,?list,?term,?list) – zero_or_one`

### sort/2

> Sorts a list in ascending order (duplicated elements are removed).

compilation flags:
  `static`
template:
  `sort(List,Sorted)`
mode – number of proofs:
  `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).

compilation flags:
  `static`
template:
  `sort(Closure,List,Sorted)`
meta-predicate template:
  `sort(3,*,*)`
mode – number of proofs:
  `sort(+callable,+list,-list) – one`

### split/4

> Splits a list into sublists of a given length. Also returns the remaining elements. Fails if the length is zero or negative.

compilation flags:
  `static`
template:
  `split(List,Length,Sublists,Remaining)`
mode – number of proofs:
  `split(+list,+integer,-list(list),-list) – zero_or_one`

### sublist/2

> The first list is a sublist of the second.

compilation flags:
  `static`
template:
  `sublist(Sublist,List)`
mode – number of proofs:
  `sublist(?list,+list) – zero_or_more`

### subsequence/3

> List is an interleaving of Subsequence and Remaining. Element order is preserved.

compilation flags:
  `static`
template:
  `subsequence(List,Subsequence,Remaining)`
mode – number of proofs:
  `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.

compilation flags:
  `static`
template:
  `subsequence(List,Length,Subsequence,Remaining)`
mode – number of proofs:
  `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.

compilation flags:
  `static`
template:
  `substitute(Old,List,New,NewList)`
mode – number of proofs:
  `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.

compilation flags:
  `static`
template:
  `subtract(List,Elements,Remaining)`
mode – number of proofs:
  `subtract(+list,+list,-list) – one`

### suffix/2

> Suffix is a suffix of List.

compilation flags:
  `static`
template:
  `suffix(Suffix,List)`
mode – number of proofs:
  `suffix(?list,+list) – zero_or_more`

### proper_suffix/2

> Suffix is a proper suffix of List.

compilation flags:
  `static`
template:
  `proper_suffix(Suffix,List)`
mode – number of proofs:
  `proper_suffix(?list,+list) – zero_or_more`

## Protected interface

(none)

## Private predicates

(none)

## Operators

### (none)

## Remarks

### (none)