protocol

permutations_protocol

Protocol for permutations operations over lists.

Availability:
logtalk_load(permutations(loader))
Author: Paulo Moura
Version: 1:0:0
Date: 2026-02-26
Compilation flags:
static
Dependencies:
(none)
Remarks:
(none)
Inherited public predicates:
(none)

Public predicates

permutations/2

Generates all permutations of a list.

Compilation flags:
static
Template:
permutations(List,Permutations)
Mode and number of proofs:
permutations(+list,-list) - one

permutation/2

True iff the second argument is a permutation of the first argument.

Compilation flags:
static
Template:
permutation(List,Permutation)
Mode and number of proofs:
permutation(+list,-list) - one_or_more

permutations/3

Generates all permutations with the given order: default, lexicographic, or shortlex.

Compilation flags:
static
Template:
permutations(List,Order,Permutations)
Mode and number of proofs:
permutations(+list,+atom,-list) - one

permutation/3

True iff the third argument is a permutation with the given order: default, lexicographic, or shortlex.

Compilation flags:
static
Template:
permutation(List,Order,Permutation)
Mode and number of proofs:
permutation(+list,+atom,-list) - one_or_more

distinct_permutations/2

Generates all distinct permutations of a list (deduplicating repeated values in the input list).

Compilation flags:
static
Template:
distinct_permutations(List,Permutations)
Mode and number of proofs:
distinct_permutations(+list,-list) - one

distinct_permutation/2

True iff the second argument is a distinct permutation of the first argument.

Compilation flags:
static
Template:
distinct_permutation(List,Permutation)
Mode and number of proofs:
distinct_permutation(+list,-list) - one_or_more

distinct_permutations/3

Generates all distinct permutations with the given order: default, lexicographic, or shortlex.

Compilation flags:
static
Template:
distinct_permutations(List,Order,Permutations)
Mode and number of proofs:
distinct_permutations(+list,+atom,-list) - one

distinct_permutation/3

True iff the third argument is a distinct permutation with the given order: default, lexicographic, or shortlex.

Compilation flags:
static
Template:
distinct_permutation(List,Order,Permutation)
Mode and number of proofs:
distinct_permutation(+list,+atom,-list) - one_or_more

k_permutations/3

Generates all K-permutations (ordered selections) of a list.

Compilation flags:
static
Template:
k_permutations(K,List,Permutations)
Mode and number of proofs:
k_permutations(+integer,+list,-list) - one

k_permutation/3

True iff the third argument is a K-permutation (ordered selection) of a list.

Compilation flags:
static
Template:
k_permutation(K,List,Permutation)
Mode and number of proofs:
k_permutation(+integer,+list,-list) - one_or_more

k_permutations/4

Generates all K-permutations with the given order: default, lexicographic, or shortlex.

Compilation flags:
static
Template:
k_permutations(K,List,Order,Permutations)
Mode and number of proofs:
k_permutations(+integer,+list,+atom,-list) - one

k_permutation/4

True iff the fourth argument is a K-permutation with the given order: default, lexicographic, or shortlex.

Compilation flags:
static
Template:
k_permutation(K,List,Order,Permutation)
Mode and number of proofs:
k_permutation(+integer,+list,+atom,-list) - one_or_more

cartesian_product/3

Generates all K-element tuples from a list with replacement where order matters.

Compilation flags:
static
Template:
cartesian_product(K,List,Tuples)
Mode and number of proofs:
cartesian_product(+integer,+list,-list) - one

derangements/2

Generates all derangements of a list.

Compilation flags:
static
Template:
derangements(List,Derangements)
Mode and number of proofs:
derangements(+list,-list) - one

derangement/2

True iff the second argument is a derangement of the first argument.

Compilation flags:
static
Template:
derangement(List,Derangement)
Mode and number of proofs:
derangement(+list,-list) - one_or_more

next_permutation/2

Returns the next permutation in lexicographic order.

Compilation flags:
static
Template:
next_permutation(Permutation,Next)
Mode and number of proofs:
next_permutation(+list,-list) - zero_or_one

previous_permutation/2

Returns the previous permutation in lexicographic order.

Compilation flags:
static
Template:
previous_permutation(Permutation,Previous)
Mode and number of proofs:
previous_permutation(+list,-list) - zero_or_one

nth_permutation/3

Returns the permutation at a given zero-based index.

Compilation flags:
static
Template:
nth_permutation(List,Index,Permutation)
Mode and number of proofs:
nth_permutation(+list,+integer,-list) - zero_or_one

permutation_index/3

Returns the zero-based index of a permutation.

Compilation flags:
static
Template:
permutation_index(List,Permutation,Index)
Mode and number of proofs:
permutation_index(+list,+list,-integer) - zero_or_one

count_permutations/2

Counts the number of permutations of a list.

Compilation flags:
static
Template:
count_permutations(List,Count)
Mode and number of proofs:
count_permutations(+list,-integer) - one

random_permutation/2

Returns a random permutation of a list.

Compilation flags:
static
Template:
random_permutation(List,Permutation)
Mode and number of proofs:
random_permutation(+list,-list) - one

Protected predicates

(none)

Private predicates

(none)

Operators

(none)