Function malachite_nz::natural::exhaustive::exhaustive_naturals
source · pub const fn exhaustive_naturals() -> ExhaustiveNaturalRangeToInfinity ⓘ
Expand description
Generates all Natural
s in ascending order.
The output is $(k)_{k=0}^{\infty}$.
The output length is infinite.
§Worst-case complexity per iteration
$T(i) = O(i)$
$M(i) = O(i)$
where $T$ is time, $M$ is additional memory, and $i$ is the iteration number.
Although the time and space complexities are worst-case linear, the worst case is very rare. If
we exclude the cases where the least-significant limb of the previously-generated value is
Limb::MAX
, the worst case space and time complexities are constant.
§Examples
use malachite_base::iterators::prefix_to_string;
use malachite_nz::natural::exhaustive::exhaustive_naturals;
assert_eq!(prefix_to_string(exhaustive_naturals(), 10), "[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, ...]");