Skip to content

Instantly share code, notes, and snippets.

@Mizzlr
Created June 16, 2016 08:54
Show Gist options
  • Save Mizzlr/ac3f6f9aa607d668de226b552a9b1d38 to your computer and use it in GitHub Desktop.
Save Mizzlr/ac3f6f9aa607d668de226b552a9b1d38 to your computer and use it in GitHub Desktop.
var AND = function(bool1){
return function(bool2){
bool1(bool2)(bool1);
};
};
// consider what happens for all combination of bool1 and bool2
// bool1(bool2)(bool1) = AND(bool1)(bool2)
// TRUE(FALSE)(TRUE) = FALSE ; TRUE returns the first argument
// TRUE(TRUE)(TRUE) = TRUE
// FALSE(TRUE)(FALSE) = FALSE ; FALSE returns the second argument
var OR = function(bool1){
return function(bool2){
bool1(bool1)(bool2);
};
};
// analyze the OR function yourself
var NOT = function(bool){
return bool(FALSE)(TRUE);
}
// when bool is TRUE, NOT(TRUE) returns FALSE
// when bool in FALSE, NOT(FALSE) returns TRUE
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment