Crate rpn_reckoner

source ·
Expand description

RPN-Reckoner

Reverse Polish Notation (: RPN) - Reckoner

Example1

let expression = String::from("1 2 +");
let solution = rpn_reckoner::eval(expression).unwrap();
println!("{}", solution); // -> 3

Example2

let expression = String::from("5 2 - 3 +");
let solution = rpn_reckoner::eval(expression).unwrap();
println!("{}", solution); // -> 6

Example3

let expression = String::from("5 2 3 ^ +");
let solution = rpn_reckoner::eval(expression).unwrap();
println!("{}", solution); // -> 13

Example4

let expression = String::from("4 ! 2 +");
let solution = rpn_reckoner::eval(expression).unwrap();
println!("{}", solution); // -> 26

Functions

The function computes RPN expressions