Skip to content

Instantly share code, notes, and snippets.

@konijn
Created April 23, 2014 14:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save konijn/11217312 to your computer and use it in GitHub Desktop.
Save konijn/11217312 to your computer and use it in GitHub Desktop.
//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) }
@konijn
Copy link
Author

konijn commented Apr 23, 2014

The evil version would not have been written if Function.name was a writeOnce property..

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment