12/08/18 14:22:49.28 .net
Both support some functional programming constructs,
but Ruby is arguably better suited to a functional programming style.
Lambdas in Python are generally very short, because lambdas in Python are
restricted to expressions and cannot contain statements.
Ruby's lambda support is far more flexible,
allowing for lambda expressions of arbitrary length.
In a similar vein, Python 2.x's closure support is
more limited than Ruby's thanks to its limited support for lexical scope.
Python 3 introduces the nonlocal keyword which addresses this limitation
by allowing assignment to variables in outer non-global scopes.
On the other hand, as of version 1.8, which is still used widely,
Ruby does not support tail-call optimization for recursive functions,
whereas Python uses a decorator to implement tail-call optimization.
Ruby 1.9 ― the current stable release ― can currently be compiled to
support tail-call optimization.
"Functional Programming - Python vs Ruby"
URLリンク(www.wikivs.com)