Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Booleans with arithmetic
// x, y :: {0,1}
var and = (x,y) => x * y,
not = (x) => 1 - x,
or = (x,y) => 1 - (1 - x) * (1 - y)
and(0,0) // 0
and(0,1) // 0
and(1,0) // 0
and(1,1) // 1
not(0) // 1
not(1) // 0
or(0,0) // 0
or(0,1) // 1
or(1,0) // 1
or(1,1) // 1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.