Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 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) });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement