Created
November 22, 2010 15:17
-
-
Save DmitrySoshnikov/710098 to your computer and use it in GitHub Desktop.
Short lambda
This file contains hidden or 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
/** | |
* 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] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Забавно придумано, но все-таки eval