DATE: Feb. 8th, 2023
This package provides a Rust library and
an executable for doing Reverse Polish Notation (: RPN) calculations.
This package's library allows for evaluating RPN expressions
by using the function rpn_reckoner::eval(expression: String) -> Result<f64, String>
.
This function takes an RPN expression as a string argument and returns a result,
either the evaluated value as a float or an error message as a string.
cargo add rpn_reckoner
```rust extern crate rpn_reckoner;
fn main() { let expression = String::from("3 2 +"); let solution = rpn_reckoner::eval(expression).unwrap(); println!("{}", solution); // -> 5 } ```
```rust extern crate rpn_reckoner;
fn main() { let expression = String::from("6 4 ! +"); let solution = rpn_reckoner::eval(expression).unwrap(); println!("{}", solution); // -> 30 } ```
bash
git clone https://github.com/Rei-Ashine/rpn-reckoner.git
To start the REPL for evaluating RPN expressions,
the command cargo run
should be run in the terminal.
``` . ├── README.md ├── Cargo.toml ├── LICENSE └── src ├── lib.rs ├── main.rs ├── operation.rs └── test.rs
Markdown 1 46 0 29 17 |- Rust 1 16 12 0 4
Rust 4 145 105 8 32 |- Markdown 1 27 0 27 0
```