pub fn exhaustive_vecs_length_inclusive_range<I: Clone + Iterator>(
a: u64,
b: u64,
xs: I,
) -> ExhaustiveVecs<I::Item, PrimitiveIntIncreasingRange<u64>, I> ⓘ
Expand description
Generates all Vec
s with lengths in $[a, b]$ and with elements from a specified iterator.
- If $a > b$, the output length is 0.
- If $a = b = 0$, the output length is 1.
- If $a < b$, $b > 0$, and
xs
is infinite, the output length is infinite. - If
xs
is finite, the output length is $$ \sum_{k=a}^b n^k, $$ where $k$ isxs.count()
.
The lengths of the output Vec
s grow logarithmically.
§Panics
Panics if $a > b$.
§Examples
use itertools::Itertools;
use malachite_base::num::exhaustive::exhaustive_unsigneds;
use malachite_base::vecs::exhaustive::exhaustive_vecs_length_inclusive_range;
let xss = exhaustive_vecs_length_inclusive_range(2, 4, 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, 2],
&[0, 3],
&[0, 1, 0],
&[1, 2],
&[0, 0, 0, 1],
&[1, 3],
&[0, 1, 1],
&[2, 0],
&[1, 0, 0],
&[2, 1],
&[1, 0, 1],
&[3, 0],
&[0, 0, 1, 0]
]
);