Function malachite_q::exhaustive::exhaustive_non_negative_rationals
source · pub fn exhaustive_non_negative_rationals(
) -> Chain<Once<Rational>, ExhaustivePositiveRationals>
Expand description
Generates all non-positive Rational
s.
Zero is generated first, followed by all the positive Rational
s. See
exhaustive_positive_rationals
for details.
The output length is infinite. The numerators and denominators of the $n$th element are $O(n^\frac{\log \phi}{\log 2})$.
§Worst-case complexity per iteration
$T(i) = O(\log i \log\log i \log\log\log i)$
$M(i) = O(\log i \log\log i)$
where $T$ is time, $M$ is additional memory, and $n$ is the iteration number.
§Examples
use malachite_base::iterators::prefix_to_string;
use malachite_q::exhaustive::exhaustive_non_negative_rationals;
assert_eq!(
prefix_to_string(exhaustive_non_negative_rationals(), 20),
"[0, 1, 1/2, 2, 1/3, 3/2, 2/3, 3, 1/4, 4/3, 3/5, 5/2, 2/5, 5/3, 3/4, 4, 1/5, 5/4, 4/7, \
7/3, ...]"
)