Function malachite_base::strings::random::random_fixed_length_strings
source · pub fn random_fixed_length_strings(
seed: Seed,
len: u64
) -> StringsFromCharVecs<RandomFixedLengthVecsFromSingle<RandomCharRange>> ⓘExpand description
Randomly generates Strings of a given length.
The probability of a particular length-$n$ String being generated is $1112064^{-\ell}$,
where $\ell$ is len.
If len is 0, the output consists of the empty String, repeated.
Expected complexity per iteration
$T(n) = O(n)$
$M(n) = O(n)$
where $T$ is time, $M$ is additional memory, and $n$ is len.
Examples
use itertools::Itertools;
use malachite_base::random::EXAMPLE_SEED;
use malachite_base::strings::random::random_fixed_length_strings;
let ss = random_fixed_length_strings(EXAMPLE_SEED, 2)
.take(10)
.collect_vec();
assert_eq!(
ss.iter().map(|cs| cs.as_str()).collect_vec().as_slice(),
&[
"\u{5f771}\u{87234}",
"\u{bcd36}\u{9e195}",
"\u{5da07}\u{36553}",
"\u{45028}\u{1cdfd}",
"\u{d8530}\u{c7f2e}",
"\u{ba4bc}\u{ff677}",
"\u{a12e2}\u{d775c}",
"\u{f827b}\u{bdf7a}",
"簅\u{15aca}",
"\u{4e5e2}\u{bb286}"
]
);