Skip to content

Instantly share code, notes, and snippets.

@theophani
Created January 25, 2011 07:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save theophani/794613 to your computer and use it in GitHub Desktop.
Save theophani/794613 to your computer and use it in GitHub Desktop.
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.
*/
@theophani
Copy link
Author

Ha! I see clearly now that in this approach, "is" is not even needed at all. Oops. :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment