Did you know ... Search Documentation:
Pack logtalk -- logtalk-3.98.0/docs/apis/_sources/permutations_protocol_0.rst.txt

.. index:: single: permutations_protocol .. _permutations_protocol/0:

.. rst-class:: right

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)

.. contents:: :local: :backlinks: top

Public predicates

.. index:: permutations/2 .. _permutations_protocol/0::permutations/2:

permutations/2 ^^^^^^^^^^^^^^^^^^

Generates all permutations of a list.

| Compilation flags: | static

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


.. index:: permutation/2 .. _permutations_protocol/0::permutation/2:

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


.. index:: permutations/3 .. _permutations_protocol/0::permutations/3:

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


.. index:: permutation/3 .. _permutations_protocol/0::permutation/3:

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


.. index:: distinct_permutations/2 .. _permutations_protocol/0::distinct_permutations/2:

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


.. index:: distinct_permutation/2 .. _permutations_protocol/0::distinct_permutation/2:

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


.. index:: distinct_permutations/3 .. _permutations_protocol/0::distinct_permutations/3:

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


.. index:: distinct_permutation/3 .. _permutations_protocol/0::distinct_permutation/3:

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


.. index:: k_permutations/3 .. _permutations_protocol/0::k_permutations/3:

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


.. index:: k_permutation/3 .. _permutations_protocol/0::k_permutation/3:

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


.. index:: k_permutations/4 .. _permutations_protocol/0::k_permutations/4:

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


.. index:: k_permutation/4 .. _permutations_protocol/0::k_permutation/4:

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


.. index:: cartesian_product/3 .. _permutations_protocol/0::cartesian_product/3:

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


.. index:: derangements/2 .. _permutations_protocol/0::derangements/2:

derangements/2 ^^^^^^^^^^^^^^^^^^

Generates all derangements of a list.

| Compilation flags: | static

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


.. index:: derangement/2 .. _permutations_protocol/0::derangement/2:

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


.. index:: next_permutation/2 .. _permutations_protocol/0::next_permutation/2:

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


.. index:: previous_permutation/2 .. _permutations_protocol/0::previous_permutation/2:

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


.. index:: nth_permutation/3 .. _permutations_protocol/0::nth_permutation/3:

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


.. index:: permutation_index/3 .. _permutations_protocol/0::permutation_index/3:

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


.. index:: count_permutations/2 .. _permutations_protocol/0::count_permutations/2:

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


.. index:: random_permutation/2 .. _permutations_protocol/0::random_permutation/2:

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)