Created
June 16, 2016 08:54
-
-
Save Mizzlr/ac3f6f9aa607d668de226b552a9b1d38 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
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