0

I have some variables

var a = true;
var b = false;
var c = true;

and propositional logic expression (in infix=a | b & c) as postfix

a b | c &

I want to evaluate the truth value.

I have found http://eddmann.com/posts/small-rpn-implementation-in-javascript/ which does it for arithmetic.

How can I do the same for just logical symbols?

Jamgreen
  • 10,329
  • 29
  • 113
  • 224
  • Since that code uses `eval()`, you need to change `&` and `|` to `&&` and `||`, since those are Javascript's logical operators. Then it should work. – Barmar Sep 09 '16 at 23:03
  • Shouldn't `t == +t ? t ...` be changed to something that checks if `t` a varable name and if it's defined? – Jamgreen Sep 10 '16 at 04:33
  • Change that to `typeof t == 'boolean'`. – Barmar Sep 10 '16 at 06:10

0 Answers0