[prev in list] [next in list] [prev in thread] [next in thread] 

List:       ruby-talk
Subject:    Re: Need examples comparing Ruby to Python
From:       Tobias Nurmiranta <spyck () lysator ! liu ! se>
Date:       2004-02-26 10:53:07
Message-ID: Pine.GSO.4.51L2.0402261145130.25026 () nazgul ! lysator ! liu ! se
[Download RAW message or body]


On Thu, 26 Feb 2004, Florian Gross wrote:
> I think it's either optional parentheses or function object access via name.

Yes, I guess the choice in Ruby is quite ok.

> Yup, you will have to backport it. I think he just used Ruby to show the
> different semantics of the original posters LISP and Python versions.
> (The LISP version returns a function which can be called to get the
> result and the Python version directly returns the result.)
>
> Backported it looks like this:
>
> def compose(f, g, x): # the result version
>    return f(g(x))
>
> def compose_callable(f, g): # the function version
>    return lambda x: f(g(x))

Yes, I just didn't have the energy to remember the Python syntax :). It's
interesting that Python added closures after several years of development,
instead of including it from the beginning. In some releases you had to
"from __future__ import nested_scopes" to enable it.

,	Tobias


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic