Created
November 16, 2012 20:19
-
-
Save fabriceleal/4090540 to your computer and use it in GitHub Desktop.
js K combinator
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
macro $K { | |
case ($literal) => { | |
(function(){ | |
return $literal; | |
}) | |
} | |
case (function $params $body) => { | |
(function(){ | |
return function $params $body; | |
}) | |
} | |
case (λ $params $body) => { | |
(function(){ | |
return function $params $body; | |
}) | |
} | |
} | |
var w = $K(123); | |
var w2 = $K(λ (b) { return b*b; }); | |
console.log(w()); | |
console.log(w2()(5)); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment