derangements_protocol — Logtalk 3.100.1

protocol

# `derangements_protocol`

Protocol for derangement operations over lists.

Availability:
`logtalk_load(derangements(loader))`
Author: Paulo Moura
Version: 1:0:0
Date: 2026-05-12
Compilation flags:
`static`
Dependencies:
(none)
Remarks:
(none)
Inherited public predicates:
(none)

## Public predicates

### `derangements/2`

Generates all derangements of a list using default order.

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 using default order.

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

### `derangements/3`

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

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

### `derangement/3`

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

Compilation flags:
`static`
Template:
`derangement(List,Order,Derangement)`
Mode and number of proofs:
`derangement(+list,+atom,-list)` - `zero_or_more`

### `distinct_derangements/2`

Generates all distinct derangements of a list using default order.

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

### `distinct_derangement/2`

True iff the second argument is a distinct derangement of the first argument using default order.

Compilation flags:
`static`
Template:
`distinct_derangement(List,Derangement)`
Mode and number of proofs:
`distinct_derangement(+list,-list)` - `zero_or_more`

### `distinct_derangements/3`

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

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

### `distinct_derangement/3`

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

Compilation flags:
`static`
Template:
`distinct_derangement(List,Order,Derangement)`
Mode and number of proofs:
`distinct_derangement(+list,+atom,-list)` - `zero_or_more`

### `nth_derangement/3`

Returns the derangement at a given zero-based index using default order.

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

### `nth_derangement/4`

Returns the derangement at a given zero-based index in the given order: `default`, `lexicographic`, or `shortlex`.

Compilation flags:
`static`
Template:
`nth_derangement(List,Order,Index,Derangement)`
Mode and number of proofs:
`nth_derangement(+list,+atom,+integer,-list)` - `zero_or_one`

### `derangement_index/3`

Returns the zero-based index of a derangement using default order.

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

### `derangement_index/4`

Returns the zero-based index of a derangement in the given order: `default`, `lexicographic`, or `shortlex`.

Compilation flags:
`static`
Template:
`derangement_index(List,Order,Derangement,Index)`
Mode and number of proofs:
`derangement_index(+list,+atom,+list,-integer)` - `zero_or_one`

### `count_derangements/2`

Counts the number of derangements of a list.

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

### `count_partial_derangements/3`

Counts the number of permutations of a list with exactly the given number of fixed points.

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

### `count_distinct_derangements/2`

Counts the number of distinct derangements of a list (deduplicating equal-valued derangements).

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

### `nth_distinct_derangement/3`

Returns the distinct derangement at a given zero-based index in default generation order.

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

### `distinct_derangement_index/3`

Returns the zero-based index of a distinct derangement in default generation order.

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

### `random_derangement/2`

Returns a random derangement of a list.

Compilation flags:
`static`
Template:
`random_derangement(List,Derangement)`
Mode and number of proofs:
`random_derangement(+list,-list)` - `zero_or_one`

### `sample_derangements/3`

Returns SampleCount random derangements of a list, sampled with replacement.

Compilation flags:
`static`
Template:
`sample_derangements(List,SampleCount,Samples)`
Mode and number of proofs:
`sample_derangements(+list,+integer,-list)` - `zero_or_one`

### `random_distinct_derangement/2`

Returns a random distinct derangement of a list (deduplicating equal-valued derangements).

Compilation flags:
`static`
Template:
`random_distinct_derangement(List,Derangement)`
Mode and number of proofs:
`random_distinct_derangement(+list,-list)` - `zero_or_one`

### `sample_distinct_derangements/3`

Returns SampleCount random distinct derangements of a list, sampled with replacement after deduplicating equal-valued derangements.

Compilation flags:
`static`
Template:
`sample_distinct_derangements(List,SampleCount,Samples)`
Mode and number of proofs:
`sample_distinct_derangements(+list,+integer,-list)` - `zero_or_one`

### `next_derangement/3`

Returns the next distinct derangement value in lexicographic order induced by the first argument.

Compilation flags:
`static`
Template:
`next_derangement(List,Derangement,Next)`
Mode and number of proofs:
`next_derangement(+list,+list,-list)` - `zero_or_one`

### `previous_derangement/3`

Returns the previous distinct derangement value in lexicographic order induced by the first argument.

Compilation flags:
`static`
Template:
`previous_derangement(List,Derangement,Previous)`
Mode and number of proofs:
`previous_derangement(+list,+list,-list)` - `zero_or_one`

## Protected predicates

(none)

## Private predicates

(none)

## Operators

(none)