5 ms·
Show HN: Tt – a Python library/cli for Boolean expressions
- timlyo 10y agoDoes it support outputting in LaTeX?
- knight123 10y agoNo, however that is a great idea I had not thought of before that I will add to the roadmap. In the meantime, if you need a somewhat-nicer looking output format, I have a basic web interface setup at http://tt-web.bwel.ch/ http://tt-web.bwel.ch/
- timlyo 10y agoMight be worth supporting a few different table markup formats. Pandoc has some common ones in it's documentation. http://pandoc.org/MANUAL.html#tables http://pandoc.org/MANUAL.html#tables Really interesting project though, I'll have to bookmark that web interface.
- knight123 10y agoThank you, I appreciate you taking the time to check out the project and point me towards pandoc. It looks like a great starting point for expanding into new output formats.
- brudgers 10y agoSeems like that might be better implemented as a different library.
- rbonvall 10y agoHi, where can I see a list of all the operators that are supported? I tried "A nor B" on the web interface to try to make it break and was surprised that it worked :)
- knight123 10y agoHi, thanks for taking the time to try it out. The operators can be found in the documentation at: http://tt.bwel.ch/en/latest/api/definitions.html#tt.definitions.operators.OPERATOR_MAPPING http://tt.bwel.ch/en/latest/api/definitions.html#tt.definiti... Admittedly, 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/operators.py#L138 https://github.com/welchbj/tt/blob/develop/tt/definitions/op...
- DKordic 10y agoIMHO [[https://en.wikipedia.org/wiki/S-expression][Symbolic https://en.wikipedia.org/wiki/S-expression][Symbolic Expressions]] are... infinitely better. Example: '(iff (not (and (P 1) (P 2))) (or (not (P 1)) (not (P 2))) )
- knight123 10y agoIt actually would not be too hard to add a separate parser for S-expressions; this would allow the existing "backend" tooling (converting to postfix, generating trees, filling tables, etc.) to be used unchanged. I actually think this would be a really powerful feature to add; thanks for the idea!
- brudgers 10y agoGreenspun's Tenth Rule: https://en.wikipedia.org/wiki/Greenspun%27s_tenth_rule https://en.wikipedia.org/wiki/Greenspun%27s_tenth_rule
- DKordic 10y agoI 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 https://en.wikipedia.org/wiki/Currying [1]: http://www.smtlib.org/ http://www.smtlib.org/ [2]: https://github.com/pysmt/pysmt https://github.com/pysmt/pysmt
- brudgers 10y agoA Lisp might be a better language choice for that use case than Python. Nothing against Lisps or Python.
- kazinator 10y agoI wrote this in a few lines of TXR Lisp as just an answer to a SO question: http://stackoverflow.com/a/34377302/1250772 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 ->).
- jwilk 10y agoWhat does "tt" stand for?