Last active
May 21, 2021 02:12
-
-
Save crgimenes/17892160f04752d46d964695f81f0d48 to your computer and use it in GitHub Desktop.
Creates a fake NAND gate and then creates all gates from NAND.
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
;;;; Creates a fake NAND gate and then creates all gates from NAND. | |
;;;; This is just an exercise, obviously has no practical application. | |
;;; NAND | |
(defun !& (a b) (if (and (= a 1) (= b 1)) 0 1)) | |
;;; NOT | |
(defun ! (a) (!& a 1)) | |
;;; AND | |
(defun && (a b) (! (!& a b))) | |
;;; OR | |
(defun || (a b) (!& (! a) (! b))) | |
;;; NOR | |
(defun nor (a b) (! (|| a b))) | |
;;; XOR | |
(defun xor (a b) (&& (|| a b) (!& a b))) | |
;;; XNOR | |
(defun xnor (a b) (! (xor a b))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment