Created
May 22, 2024 17:39
-
-
Save wpcarro/a72f97cffe13f49ca541e46b02b46c93 to your computer and use it in GitHub Desktop.
Logic gates from NOT, OR
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
// NOT: given | |
// OR: given | |
// NOR: derived | |
// AND: derived | |
// NAND: derived | |
// XOR: derived | |
// XNOR: derived | |
function nor(x: boolean, y: boolean): boolean { | |
return !(x || y); | |
} | |
function and(x: boolean, y: boolean): boolean { | |
return !(!x || !y); | |
} | |
function nand(x: boolean, y: boolean): boolean { | |
return !and(x, y); | |
} | |
function xor(x: boolean, y: boolean): boolean { | |
return and(!x, y) || and(x, !y); | |
} | |
function xnor(x: boolean, y: boolean): boolean { | |
return !xor(x, y); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment