multisets_protocol — Logtalk 3.100.1

protocol

# `multisets_protocol`

Protocol for multiset operations over lists.

Availability:
`logtalk_load(multisets(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

### `multisets/3`

Generates all K-multisets (unordered K-element selections with replacement) of a list using default order.

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

### `multiset/3`

True iff the third argument is a K-multiset with replacement of a list using default order.

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

### `multisets/4`

Generates all K-multisets with the given order: `default` or `lexicographic`.

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

### `multiset/4`

True iff the fourth argument is a K-multiset with replacement with the given order: `default` or `lexicographic`.

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

### `distinct_multisets/3`

Generates all distinct K-multisets (deduplicating repeated values in the input list) using default order.

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

### `distinct_multiset/3`

True iff the third argument is a distinct K-multiset with replacement of a list using default order.

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

### `distinct_multisets/4`

Generates all distinct K-multisets with the given order: `default` or `lexicographic`.

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

### `distinct_multiset/4`

True iff the fourth argument is a distinct K-multiset with replacement with the given order: `default` or `lexicographic`.

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

### `nth_multiset/4`

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

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

### `nth_multiset/5`

Returns the K-multiset at a given zero-based index in the given order: `default` or `lexicographic`.

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

### `multiset_index/4`

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

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

### `multiset_index/5`

Returns the zero-based index of a K-multiset in the given order: `default` or `lexicographic`.

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

### `count_multisets/3`

Counts the number of K-multisets with replacement of a list.

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

### `count_distinct_multisets/3`

Counts the number of distinct K-multisets with replacement of a list (deduplicating repeated values in the input list).

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

### `nth_distinct_multiset/4`

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

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

### `distinct_multiset_index/4`

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

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

### `random_multiset/3`

Returns a random K-multiset with replacement of a list.

Compilation flags:
`static`
Template:
`random_multiset(K,List,Multiset)`
Mode and number of proofs:
`random_multiset(+integer,+list,-list)` - `zero_or_one`

### `sample_multisets/4`

Returns SampleCount random K-multisets with replacement of a list, sampled with replacement.

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

### `random_distinct_multiset/3`

Returns a random distinct K-multiset with replacement of a list (deduplicating repeated values in the input list).

Compilation flags:
`static`
Template:
`random_distinct_multiset(K,List,Multiset)`
Mode and number of proofs:
`random_distinct_multiset(+integer,+list,-list)` - `zero_or_one`

### `sample_distinct_multisets/4`

Returns SampleCount random distinct K-multisets with replacement of a list, sampled with replacement after deduplicating repeated values in the input list.

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

### `next_multiset/3`

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

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

### `previous_multiset/3`

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

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

## Protected predicates

(none)

## Private predicates

(none)

## Operators

(none)