pub fn random_char_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 half-open interval $[a, b)$.

$a$ must be less than $b$. This function cannot create a range that includes char::MAX; for that, use random_char_inclusive_range.

$$ P(x) = \begin{cases} \frac{1} {\mathrm{char\_to\_contiguous\_range(b)}-\mathrm{char\_to\_contiguous\_range(a)}} & \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 \geq b$.

Examples

use malachite_base::chars::random::random_char_range;
use malachite_base::random::EXAMPLE_SEED;

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