pub fn exhaustive_rationals_with_denominator_inclusive_range(
    d: Natural,
    a: Rational,
    b: Rational
) -> RationalsWithDenominator<ExhaustiveIntegerRange> 
Expand description

Generates all Rationals in the closed range $[a, b]$ and with a specific denominator, in order of increasing absolute value.

When two Rationals have the same absolute value, the positive one comes first.

The output satisfies $(|x_i|, \operatorname{sgn}(-x_i)) <_\mathrm{lex} (|x_j|, \operatorname{sgn}(-x_j))$ whenever $i < j$.

The output length is infinite.

§Worst-case complexity per iteration

$T(i) = O(\log i (\log \log i)^2 \log\log\log i)$

$M(i) = O(\log i \log \log i)$

where $T$ is time, $M$ is additional memory, and $i$ is the iteration number.

§Panics

Panics if d is zero or if $a < b$.

§Examples

use itertools::Itertools;
use malachite_base::strings::ToDebugString;
use malachite_nz::natural::Natural;
use malachite_q::exhaustive::exhaustive_rationals_with_denominator_inclusive_range;
use malachite_q::Rational;

assert_eq!(
    exhaustive_rationals_with_denominator_inclusive_range(
        Natural::from(2u32),
        Rational::from_signeds(1i32, 3),
        Rational::from_signeds(5i32, 2)
    ).collect_vec().to_debug_string(),
    "[1/2, 3/2, 5/2]"
);
assert_eq!(
    exhaustive_rationals_with_denominator_inclusive_range(
        Natural::from(2u32),
        Rational::from_signeds(-5i32, 3),
        Rational::from_signeds(5i32, 2)
    ).collect_vec().to_debug_string(),
    "[1/2, -1/2, 3/2, -3/2, 5/2]"
);
assert_eq!(
    exhaustive_rationals_with_denominator_inclusive_range(
        Natural::from(10u32),
        Rational::try_from_float_simplest(std::f64::consts::E).unwrap(),
        Rational::try_from_float_simplest(std::f64::consts::PI).unwrap(),
    ).collect_vec().to_debug_string(),
    "[29/10, 31/10]"
);