Created
October 11, 2024 21:15
-
-
Save takaheraw/62028437024f853c65bdf6566e1db0a7 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
puts "否定論理積 NAND" | |
NAND = ->(x, y) { (x & y) == 0 ? 1 : 0 } | |
puts NAND[0, 0] | |
puts NAND[0, 1] | |
puts NAND[1, 0] | |
puts NAND[1, 1] | |
puts "否定 NOT" | |
NOT = ->(x) { NAND[x, x] } | |
puts NOT[0] | |
puts NOT[1] | |
puts "論理積 AND" | |
AND = ->(x, y) { NOT[NAND[x, y]] } | |
puts AND[0, 0] | |
puts AND[0, 1] | |
puts AND[1, 0] | |
puts AND[1, 1] | |
puts "論理和 OR" | |
OR = ->(x, y) { NAND[NOT[x], NOT[y]] } | |
puts OR[0, 0] | |
puts OR[0, 1] | |
puts OR[1, 0] | |
puts OR[1, 1] | |
puts "排他的論理和 XOR" | |
XOR = ->(x, y) { NAND[NAND[x, NOT[y]], NAND[NOT[x], y]] } | |
puts XOR[0, 0] | |
puts XOR[0, 1] | |
puts XOR[1, 0] | |
puts XOR[1, 1] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment