Created
September 29, 2017 03:58
-
-
Save groeneman/5a7779d511a783d35e3648c372b2f1ec to your computer and use it in GitHub Desktop.
Higher order functions
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 Q = function(f, g){ | |
return function(x, y){ | |
return f(x, y) > g(x, y) | |
} | |
} | |
var addition = function(a, b) { return a + b } | |
var subtraction = function(a, b) { return a - b } | |
var isAddingGreaterThanSubtracting = Q(addition, subtraction) | |
var result = isAddingGreaterThanSubtracting(1, 2) | |
console.log(result) | |
console.log(typeof result) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment