From: Chad Perrin Date: 2007-04-16T02:48:59+09:00 Subject: Re: Ruby Truth Table Generator On Mon, Apr 16, 2007 at 01:21:05AM +0900, Stephen Duncan wrote: > I was working on some code (in Java), which had a somewhat complicated > nested pair of if statements. It occurred to me that I could try to > do some boolean algebra and see if I could simplify the expression. > Since I hadn't done that in probably 7+ years, I screwed up; a lot. I > find myself needing to generate the truth tables ( > http://en.wikipedia.org/wiki/Truth_table ) to verify my work fairly > frequently. So I developed a Ruby program to generate truth tables > for me: http://jrduncans.googlecode.com/svn/trunk/truthtable The core > code is here: > http://jrduncans.googlecode.com/svn/trunk/truthtable/lib/truthtable.rb > > I'd like to say I just whipped this up, but I'm still a Ruby-newbie, > so this took me a few days. I'd love to get some feedback on the > code. I'd also like to know if anybody finds it actually useful for > them, and if so how I should go about making it easier to get/find. > If you run 'rake install_gem', you'll get an executable "truthtable" > that allows you to pass in the expression on the command-line to > generate the truth table. > > Thanks in advance to anyone who takes the time to check it out, Excellent! I've been thinking of using Perl or Ruby to write a truth table generator, and just haven't gotten around to it. I'll definitely have a look at yours. Thank you! -- CCD CopyWrite Chad Perrin [ http://ccd.apotheon.org ] "It's just incredible that a trillion-synapse computer could actually spend Saturday afternoon watching a football game." - Marvin Minsky