pub fn lex_unique_vecs_fixed_length<I: Iterator>(
    k: u64,
    xs: I
) -> LexUniqueVecsFixedLength<I>Notable traits for LexUniqueVecsFixedLength<I>impl<I: Iterator> Iterator for LexUniqueVecsFixedLength<I> where
    I::Item: Clone
type Item = Vec<I::Item>;
where
    I::Item: Clone
Expand description

Generates Vecs of a given length with elements from a single iterator, such that each Vec has no repeated elements.

The source iterator should not repeat any elements, but this is not enforced.

The order is lexicographic with respect to the order of the element iterator.

If $k$ is 0, the output length is 1.

If $k$ is nonzero and the input iterator is infinite, the output length is also infinite.

If $k$ is nonzero and the input iterator length is $n$, the output length is $$ (n)_ k = \prod_ {i=0}^{k-1}(n - i) = frac{n!}{(n-k)!}. $$

If $k$ is 0, the output consists of one empty Vec.

If xs is empty, the output is also empty, unless $k$ is 0.

Examples

extern crate itertools;

use itertools::Itertools;
use malachite_base::vecs::exhaustive::lex_unique_vecs_fixed_length;

let xss = lex_unique_vecs_fixed_length(4, 1..=6).take(20).collect_vec();
assert_eq!(
    xss.iter().map(Vec::as_slice).collect_vec().as_slice(),
    &[
        &[1, 2, 3, 4],
        &[1, 2, 3, 5],
        &[1, 2, 3, 6],
        &[1, 2, 4, 3],
        &[1, 2, 4, 5],
        &[1, 2, 4, 6],
        &[1, 2, 5, 3],
        &[1, 2, 5, 4],
        &[1, 2, 5, 6],
        &[1, 2, 6, 3],
        &[1, 2, 6, 4],
        &[1, 2, 6, 5],
        &[1, 3, 2, 4],
        &[1, 3, 2, 5],
        &[1, 3, 2, 6],
        &[1, 3, 4, 2],
        &[1, 3, 4, 5],
        &[1, 3, 4, 6],
        &[1, 3, 5, 2],
        &[1, 3, 5, 4],
    ]
);