pub fn random_values_from_vec<T>(
seed: Seed,
xs: Vec<T>,
) -> RandomValuesFromVec<T> ⓘwhere
T: Clone,Expand description
Uniformly generates a random value from a nonempty Vec.
The iterator owns the data. It may be more convenient for the iterator to return references to a
pre-existing slice, in which case you may use
random_values_from_slice instead.
The output length is infinite.
$P(x) = 1/n$, where $n$ is xs.len().
§Panics
Panics if xs is empty.
§Examples
use itertools::Itertools;
use malachite_base::random::EXAMPLE_SEED;
use malachite_base::vecs::random_values_from_vec;
let xs = vec![2, 3, 5, 7, 11];
assert_eq!(
random_values_from_vec(EXAMPLE_SEED, xs)
.take(10)
.collect_vec(),
&[3, 7, 3, 5, 11, 3, 5, 11, 2, 2]
);