Search code examples
javascriptif-statementbooleanxor

Boolean product and semplify


I have a question for you.

For example I have this boolean expression:

(((A AND B) OR C) AND D) AND ((K AND Z) OR (J AND H)) AND Y

THis is just an example but I can have a lot of expression like this, I've to write an algo in JavaScript for make this expression simple and representable through a json.

The basic idea is to use boolean product like that:

(A AND B) OR C = (A OR C) AND (B OR C)

But how can I write something automatic for do that?

Thank you.


Solution

  • You could check out an existing library like riichard/boolean-parser-js on GitHub.