Skip to content

Instantly share code, notes, and snippets.

@heymatthenry
Created January 3, 2010 19:29
Show Gist options
  • Select an option

  • Save heymatthenry/268095 to your computer and use it in GitHub Desktop.

Select an option

Save heymatthenry/268095 to your computer and use it in GitHub Desktop.
Compare & contrast how different languages use lambdas
(function(x){return x*x})(3)
/* 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);
(lambda x: x*x)(3)
# 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