pub fn random_char_inclusive_range(
    seed: Seed,
    a: char,
    b: char
) -> RandomCharRangeNotable traits for RandomCharRangeimpl Iterator for RandomCharRange type Item = char;
Expand description

Uniformly generates random chars in the closed interval $[a, b]$.

$a$ must be less than or equal to $b$.

$$ P(x) = \begin{cases} \frac{1} {\mathrm{char\_to\_contiguous\_range(b)}-\mathrm{char\_to\_contiguous\_range(a)} +1} & \text{if} \quad a \leq x < b \\ 0 & \text{otherwise} \end{cases} $$

The output length is infinite.

Expected complexity per iteration

Constant time and additional memory.

Panics

Panics if $a > b$.

Examples

use malachite_base::chars::random::random_char_inclusive_range;
use malachite_base::random::EXAMPLE_SEED;

assert_eq!(
    random_char_inclusive_range(EXAMPLE_SEED, 'a', 'z')
        .take(50)
        .collect::<String>()
        .as_str(),
    "rlewrsgkdlbeouylrelopxqkoonftexoshqulgvonioatekqes"
)