Crate polishexpr

source ·
Expand description

PolishEvaluator

Poor implementation of of polish expression evaluator

Evaluator of expressions written in reverse polish notation. The list of supported functions are:

  • Arithmetic functions: +, -, *, /
  • sin: sine
  • cos: cosine
  • ln: natural logarithm
  • exp: exponent
  • sqrt: square root

Arguments for these functions could be as usual constants, written as numbers, as variables, written as $var_number ($0, for example). The variable number is zero based index of variables vector.

Examples

use polishexpr::PolishEvaluator;

let pe = PolishEvaluator::new("$0 $1 +", &[2.0, 2.0]);
let result = pe.evaluate().expect("get the sum result");
assert_eq!(4.0, result);

Structs

  • Data structure that wraps an expression and a vector of variables.