Function malachite_base::vecs::exhaustive::exhaustive_vecs_min_length
source · pub fn exhaustive_vecs_min_length<I: Clone + Iterator>(
min_length: u64,
xs: I,
) -> ExhaustiveVecs<I::Item, PrimitiveIntIncreasingRange<u64>, I> ⓘ
Expand description
Generates all Vec
s with a minimum length and with elements from a specified iterator.
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::num::exhaustive::exhaustive_unsigneds;
use malachite_base::vecs::exhaustive::exhaustive_vecs_min_length;
let xss = exhaustive_vecs_min_length(2, exhaustive_unsigneds::<u32>())
.take(20)
.collect_vec();
assert_eq!(
xss.iter().map(Vec::as_slice).collect_vec().as_slice(),
&[
&[0, 0][..],
&[0, 0, 0],
&[0, 1],
&[0, 0, 0, 0],
&[1, 0],
&[0, 0, 1],
&[1, 1],
&[0, 0, 0, 0, 0],
&[0, 2],
&[0, 1, 0],
&[0, 3],
&[0, 0, 0, 1],
&[1, 2],
&[0, 1, 1],
&[1, 3],
&[0, 0, 0, 0, 0, 0],
&[2, 0],
&[1, 0, 0],
&[2, 1],
&[0, 0, 1, 0]
]
);