Hacker News new | ask | show | jobs
by kazinator 3381 days ago
I wrote this in a few lines of TXR Lisp as just an answer to a SO question:

http://stackoverflow.com/a/34377302/1250772

All code is in the answer. Parsing the infix, and generating the "pretty" truth table over all variables.

An easy-to use declarative mechanism is there for defining operators on multiple precedence levels with different arities. (All you do is instantiate an object with new for each supported operator). Operators either have names that denote existing functions in TXR Lisp, or for any that are not existing Boolean functions, you just define the function (like I did for ->).