Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/nathanielknight/iter-rationals
A fixed size, linear time, no-std iterator over the rational numbers.
https://github.com/nathanielknight/iter-rationals
algorithms mathematics no-std rust-lang
Last synced: 3 days ago
JSON representation
A fixed size, linear time, no-std iterator over the rational numbers.
- Host: GitHub
- URL: https://github.com/nathanielknight/iter-rationals
- Owner: nathanielknight
- License: mpl-2.0
- Created: 2022-08-30T01:05:06.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2023-03-09T00:51:12.000Z (almost 2 years ago)
- Last Synced: 2025-01-02T01:23:24.637Z (3 days ago)
- Topics: algorithms, mathematics, no-std, rust-lang
- Language: Rust
- Homepage:
- Size: 14.6 KB
- Stars: 2
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
Awesome Lists containing this project
README
# iter-rationals
[![crate](https://img.shields.io/crates/v/iter-rationals.svg)](https://crates.io/crates/iter-rationals)
[![documentation](https://docs.rs/iter-rationals/badge.svg)](https://docs.rs/iter-rationals)
[![main](https://github.com/nathanielknight/iter-rationals/actions/workflows/main.yml/badge.svg)](https://github.com/nathanielknight/iter-rationals/actions/workflows/main.yml)This crate implements an iterator over the [rational numbers] which:
* yields each number once-and-only-once,
* requires only a fixed amount of memory, and
* yields successive values with a fixed amount of arithmetic operations.[rational numbers]: https://simple.wikipedia.org/wiki/Rational_number
The algorithm is described in [Functional Pearl: Enumerating the Rationals] by
Gibbons, Lester, and Bird; see the paper for an explanation of how it works.[Functional Pearl: Enumerating the Rationals]: http://www.cs.ox.ac.uk/people/jeremy.gibbons/publications/rationals.pdf
# Usage
```rust
use iter_rationals::Rationals;fn main() {
let rs = Rationals::::new();for r in rs.take(20) {
println!("{r}");
}
}
```# Installation
Add this dependency to your `Cargo.toml`:
```
iter-rationals = "0.1"
```or on the command line:
```
cargo add iter-rationals
```# License