Show HN: Tt – a Python library/cli for Boolean expressions
github.com
github.com
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 ->).
Example: '(iff (not (and (P 1) (P 2))) (or (not (P 1)) (not (P 2))) )
I forgot to mention SMT-LIB[1] and pySMT[2]. I don't want to say their are optimal, I just think You might find it interesting.
I think it would be even better with Curryed[0] Functions. As an example ``'(f a1 a2)'' is just a Syntactic Sugar for ``'((f a1) a2)''.
Don't forget something like `help' in Python :) .
[0]: https://en.wikipedia.org/wiki/Currying
[1]: http://www.smtlib.org/
[2]: https://github.com/pysmt/pysmtAdmittedly, this is poorly formatted and I'm working on cleaning that up. The definition in the code is a little easier to read and can be found here: https://github.com/welchbj/tt/blob/develop/tt/definitions/op...
http://pandoc.org/MANUAL.html#tables
Really interesting project though, I'll have to bookmark that web interface.