Skip to content

Instantly share code, notes, and snippets.

@webbower
Last active August 29, 2015 14:05
Show Gist options
  • Save webbower/0b9b72ee387c2127cfbe to your computer and use it in GitHub Desktop.
Save webbower/0b9b72ee387c2127cfbe to your computer and use it in GitHub Desktop.
Misc functional utilities
// Requires tester.js for isFunction()
function not(val) {
return !(value);
}
function unbind(fn) {
return function() {
return fn.apply(arguments[0], Array.prototype.slice.call(arguments, 1));
};
}
function result(val) {
return isFunction(val) ? val() : val;
}
function ite(iff, thn, els) {
return result(result(iff) ? thn : els);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment