Created
January 25, 2011 07:12
-
-
Save theophani/794613 to your computer and use it in GitHub Desktop.
This file contains 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 or = function or(a, b) { | |
return a || b; | |
}; | |
var and = function and(a, b) { | |
return a && b; | |
}; | |
var not = function not(a) { | |
return !a; | |
}; | |
var is = function is(f) { | |
if (f === true) return true; | |
if (f === false) return false; | |
if (typeof(f) === 'function') { | |
this[f.name](arguments[0], arguments[1]); | |
}; | |
}; | |
// test | |
is( or( true, and( true, not(false) ) ) ); | |
/* | |
Note: putting the and/or/not in the 'is' closure does not work | |
in this set-up, since the arguments get evaluated first, outside. | |
*/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Ha! I see clearly now that in this approach, "is" is not even needed at all. Oops. :)