Last active
March 14, 2016 12:42
-
-
Save chrisguitarguy/0a18292245ad05bfdec1 to your computer and use it in GitHub Desktop.
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
(defn perceptron [inputs weights bias] | |
{:pre [(= (count inputs) (count weights))]} | |
(let [combined (map * inputs weights)] | |
(if (< (+ (apply + combined) bias) 1) 0 1))) | |
(defn nand [one two] | |
(perceptron [one two] [-2 -2] 3)) | |
(defn adder [x y] | |
"Returns a vector of [carry-bit sum-bit]" | |
(let [f (nand x y) | |
s (nand f f)] | |
[s (nand (nand x f) (nand s f))])) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment