Created
April 23, 2014 14:26
-
-
Save konijn/11217312 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
//Good | |
function lambdafy( f ) | |
{ | |
return function lambdafier() { | |
var args = Array.prototype.slice.call(arguments); | |
return function lambda(){ | |
f.apply( this , args ); | |
} | |
} | |
} | |
//Evil, evil, evil | |
function λ( f ) | |
{ | |
var name = 'λ' + f.name, lambda; | |
eval( 'lambda = function ' + name + '() {var a = Array.prototype.slice.call(arguments);return function ' + f.name + '(){f.apply(this,a);}}'); | |
return lambda; | |
} | |
function hello( s ){ console.log(s) } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
The evil version would not have been written if Function.name was a writeOnce property..