Created
January 3, 2010 19:29
-
-
Save heymatthenry/268095 to your computer and use it in GitHub Desktop.
Compare & contrast how different languages use lambdas
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
| (function(x){return x*x})(3) |
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
| /* if anybody knows a better way to execute | |
| the closure without that variable, I'm all ears */ | |
| $square = create_function('$x', 'return $x*$x;'); $square(3); |
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
| (lambda x: x*x)(3) |
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
| # 1.8.x | |
| (lambda {|x| x*x}).call(3) | |
| # 1.9.x | |
| (->(x) {x*x}).call(3) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment