Function malachite_base::vecs::exhaustive::shortlex_vecs_min_length
source · pub fn shortlex_vecs_min_length<I: Clone + Iterator>(
min_length: u64,
xs: I,
) -> ShortlexVecs<I::Item, PrimitiveIntIncreasingRange<u64>, I> ⓘ
Expand description
Generates all Vec
s with a minimum length and with elements from a specified iterator, in
shortlex order.
Shortlex order means that the Vec
s are output from shortest to longest, and Vec
s of the
same length are output in lexicographic order with respect to the ordering of the Vec
elements specified by the input iterator.
xs
must be finite; if it’s infinite, only Vec
s of length min_length
(or 0 and 1, if
min_length
is 0) are ever produced.
If xs
is empty and min_length
is 0, the output length is 1; if xs
is empty and
min_length
is greater than 0, the output is empty; otherwise, the output is infinite.
The lengths of the output Vec
s grow logarithmically.
§Examples
use itertools::Itertools;
use malachite_base::bools::exhaustive::exhaustive_bools;
use malachite_base::vecs::exhaustive::shortlex_vecs_min_length;
let bss = shortlex_vecs_min_length(2, exhaustive_bools())
.take(20)
.collect_vec();
assert_eq!(
bss.iter().map(Vec::as_slice).collect_vec().as_slice(),
&[
&[false, false][..],
&[false, true],
&[true, false],
&[true, true],
&[false, false, false],
&[false, false, true],
&[false, true, false],
&[false, true, true],
&[true, false, false],
&[true, false, true],
&[true, true, false],
&[true, true, true],
&[false, false, false, false],
&[false, false, false, true],
&[false, false, true, false],
&[false, false, true, true],
&[false, true, false, false],
&[false, true, false, true],
&[false, true, true, false],
&[false, true, true, true]
]
);