Lambdas
Lambda definitions:
# Python: g = lambda x: x + 2 print g(8); # Perl 6: $g = -> $x { $x + 2 } print $g(8); # Perl 5: $g = sub { my ($x) = @_; $x + 2; } say $g(8);
Python and Perl 6 | Similarities between Python and Perl 6 | #23 |
Lambda definitions:
# Python: g = lambda x: x + 2 print g(8); # Perl 6: $g = -> $x { $x + 2 } print $g(8); # Perl 5: $g = sub { my ($x) = @_; $x + 2; } say $g(8);
Copyright © 2010 http://www.pmichaud.com/2010/pres/ |