Function malachite_base::vecs::exhaustive::exhaustive_vecs
source · pub fn exhaustive_vecs<I: Clone + Iterator>(
xs: I,
) -> ExhaustiveVecs<I::Item, PrimitiveIntIncreasingRange<u64>, I> ⓘ
Expand description
Generates all Vec
s with elements from a specified iterator.
If xs
is empty, the output length is 1; 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;
let xss = exhaustive_vecs(exhaustive_unsigneds::<u32>())
.take(20)
.collect_vec();
assert_eq!(
xss.iter().map(Vec::as_slice).collect_vec().as_slice(),
&[
&[][..],
&[0],
&[1],
&[0, 0, 0],
&[2],
&[0, 0],
&[3],
&[0, 0, 0, 0],
&[4],
&[0, 1],
&[5],
&[0, 0, 1],
&[6],
&[1, 0],
&[7],
&[0, 0, 0, 0, 0],
&[8],
&[1, 1],
&[9],
&[0, 1, 0]
]
);