Skip to content

Instantly share code, notes, and snippets.

@fabriceleal
Created November 16, 2012 20:19
Show Gist options
  • Save fabriceleal/4090540 to your computer and use it in GitHub Desktop.
Save fabriceleal/4090540 to your computer and use it in GitHub Desktop.
js K combinator
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