zslevi <zslevi / gmail.com> writes:

> foo = lambda {|x|
> return lambda {|y| return x+y}}
>
> puts (foo.call(3)).call(4)
>
> It works finally, but it's just too verbose.
> Can anyone suggest a shorter, programmer friendlier way of writing
> this?

What about:

irb(main):038:0> (foo = (lambda {|x| (lambda {|y| (x + y)})}))
#<Proc:0x00007f797ea420f0@(irb):38>
irb(main):039:0> (funcall (funcall foo,3),4)
7

(See the "functional programming" thread).

or you could write:

    (def uncurry(f,arg)
       (funcall f,arg)
    end)

and then:

    (uncurry (uncurry foo,3),4)

-- 
__Pascal Bourguignon__