Last active
December 11, 2015 22:18
-
-
Save lcowell/4668631 to your computer and use it in GitHub Desktop.
add ops in to expand your truth table
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
ops = [ | |
"l && r", | |
"l || r", | |
"l ^ r", | |
"!l && !r", | |
"!(l ^ r)" | |
] | |
ops.each do |key| | |
puts key.center(12) | |
puts "=" * 20 | |
[true, false].product([true, false]).each do |l, r| | |
printf "|%5s|%5s|%5s|\n", l, r, eval(key) | |
end | |
puts "=" * 20 | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment