pub fn random_vecs_length_inclusive_range<I: Iterator>(
    seed: Seed,
    a: u64,
    b: u64,
    xs_gen: &dyn Fn(Seed) -> I
) -> RandomVecs<I::Item, RandomUnsignedInclusiveRange<u64>, I>
Expand description

Generates random Vecs with lengths in $[a, b]$, using elements from an iterator.

The lengths of the Vecs are sampled from a uniform distribution on $[a, b]$. $a$ must be less than or equal to $b$.

$$ P((x_i)_{i=0}^{n-1}) = \begin{cases} \frac{1}{b-a+1}\prod_{i=0}^{n-1}P(x_i) & \text{if} \quad a \leq n \leq b, \\ 0 & \text{otherwise}. \end{cases} $$

xs_gen must be infinite.

Panics

Panics if $a > b$.

Examples

use itertools::Itertools;
use malachite_base::num::random::random_primitive_ints;
use malachite_base::random::EXAMPLE_SEED;
use malachite_base::vecs::random::random_vecs_length_inclusive_range;

let xs = random_vecs_length_inclusive_range(EXAMPLE_SEED, 2, 4, &random_primitive_ints::<u8>);
let values = xs.take(20).collect_vec();
assert_eq!(
    values.iter().map(Vec::as_slice).collect_vec().as_slice(),
    &[
        &[85, 11, 136][..],
        &[200, 235, 134, 203],
        &[223, 38, 235],
        &[217, 177, 162, 32],
        &[166, 234, 30, 218],
        &[90, 106, 9],
        &[216, 204],
        &[151, 213, 97],
        &[253, 78],
        &[91, 39, 191, 175],
        &[170, 232, 233, 2],
        &[35, 22, 217],
        &[198, 114, 17, 32],
        &[173, 114, 65],
        &[121, 222, 173, 25],
        &[144, 148, 79, 115],
        &[52, 73, 69, 137],
        &[91, 153],
        &[178, 112, 34, 95],
        &[106, 167]
    ]
);