Skip to content

Instantly share code, notes, and snippets.

@19h
Created August 7, 2012 09:31
Show Gist options
  • Select an option

  • Save 19h/3283806 to your computer and use it in GitHub Desktop.

Select an option

Save 19h/3283806 to your computer and use it in GitHub Desktop.
Implementing trivial logic gates
xor = function (a, b) { return (a && !b || !a && b);}
not = function (a) { return !a; }
and = function (a, b) { return (a && b); }
or = function (a,b){ return (a || b); }
nand = function (a,b){ return !(a && b); }
nor = function (a,b) { return !( a || b ); }
xnor = function (a,b) { return !(a && !b || !a && b); }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment