Skip to content

Instantly share code, notes, and snippets.

@groeneman
Created September 29, 2017 03:58
Show Gist options
  • Save groeneman/5a7779d511a783d35e3648c372b2f1ec to your computer and use it in GitHub Desktop.
Save groeneman/5a7779d511a783d35e3648c372b2f1ec to your computer and use it in GitHub Desktop.
Higher order functions
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