Skip to content

Instantly share code, notes, and snippets.

@DmitrySoshnikov
Created November 22, 2010 15:17
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 DmitrySoshnikov/710098 to your computer and use it in GitHub Desktop.
Save DmitrySoshnikov/710098 to your computer and use it in GitHub Desktop.
Short lambda
/**
* Short notation for expression funargs - λ
* (not for production use, but just for fun,
* since closures are not supported -> only
* operations on passed argument "x")
*
* by Dmitry A. Soshnikov
*/
function λ(code) {
return Function('x', 'return ' + code);
}
// tests
[1, 2, 3, 4].map(λ('x * 2')); // [2, 4, 6, 8]
@freeart
Copy link

freeart commented Nov 23, 2010

Забавно придумано, но все-таки eval

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