2 releases
0.1.1 | Jan 11, 2024 |
---|---|
0.1.0 | Jan 11, 2024 |
#1195 in Math
4KB
RPN(Reverse Polish Notation) Calc
Reverse Polish notation (RPN) Calc.
Example
fn main() {
let src = String::from("1 2 + 3 * ");
let a = hkkim_lib_wikibooks_rpn_test::eval(src).unwrap();
println!("{}", a); // →9
}
fn main() {
let result = hkkim_lib_wikibooks_rpn_test::eval_str("1 2 3 * +");
println!("{}", result); // →7
}
use hkkim_lib_wikibooks_rpn_test as rpn_calc;
fn main() {
let src = "2 3 4 * +".to_string();
let ans = rpn_calc::eval(src).unwrap();
println!("{}", ans);
}
lib.rs
:
RPN Calc
Reverse Polish notation (RPN) Calc.
Example 1
let src = String::from("1 2 + 3 * ");
let a = hkkim_lib_wikibooks_rpn_test::eval(src).unwrap();
println!("{}", a); // →9
Example 2
use hkkim_lib_wikibooks_rpn_test as rpn_calc;
let src = "2 3 4 * +".to_string();
let ans = rpn_calc::eval(src).unwrap();
println!("{}", ans);