-
-
Save mdunsmuir/8f9d33822929a15576ca 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
function fix(f) { | |
return function(x) { | |
return f(x)(fix(f)); | |
} | |
} | |
var fac = function(x) { | |
if(x == 1) { | |
return function(_) { | |
return 1; | |
} | |
} else { | |
return function(r) { | |
return x * r(x - 1); | |
} | |
} | |
} | |
console.log("The factorial of 5 is " + fix(fac)(5)); | |
var torture = function(_) { | |
return function(r) { | |
console.log("I'm JavaScript and I'm a steaming pile of dog shit"); | |
r(undefined); | |
} | |
} | |
fix(torture)(undefined); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment