Tobias Nurmiranta schrieb:

> Hi,

Moin!

> Given "oneplus = lambda {|x| x + 1}" wouldn't it be possible to call the
> function with "oneplus(1)", implemented so that the interpreter checks if
> it is a Method instance, and then calls the method. Then you wouldn't have
> to have several ways to call a function.

Yes, but it wouldn't be possible to call it without parentheses and 
there would be other semantic differences.

I think it's either optional parentheses or function object access via name.

>>The Python version of compose is more like this ...
>>  def compose(f, g, x)
>>    f[g[x]]
>>  end
> My python interpreter (2.3.2) doesn't accept this code.

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))

Regards,
Florian Gross