Last active
April 14, 2019 21:58
-
-
Save dance2die/6a002c4d417703cc31c0c02f8bbfe067 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
const xor = (a, b) => Boolean(a) !== Boolean(b); | |
const and = (a, b) => Boolean(a) && Boolean(b); | |
const toBit = predicate => (a, b) => (predicate(a, b) ? 1 : 0); | |
const xorBit = toBit(xor); | |
const andBit = toBit(and); | |
const halfAdder = (a, b) => ({ c: andBit(a, b), s: xorBit(a, b) }); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment