"Christian Szegedy" <szegedy / nospam.or.uni-bonn.de> wrote in message
news:3D902512.9060702 / nospam.or.uni-bonn.de...
> Christoph wrote:
> > "Christian Szegedy"
> > ...
> >
> >>Using blocks has some other benevolent psychological
> >>and aesthetical aspect: it prevents an inflation of parenthesis.
> >>Whatever you prefer: do ... end or
> >>{ ... }, it gives valuable hints: this is a piece
> >>of executable code, while the CAML, LISP and smalltalk
> >>syntax is much less balanced in my eyes.
> >>
> >>Therefore, I think that Ruby is at least as elegant
> >>and powerful in handling functional features as the functional languges.
> >
> >
> > Try writing something as seemly simple as a functional
> > Proc composition in Ruby (preserving arity etc.)
> >
> > class Proc
> >     def *(an_other_proc)
> >           ..
> >      end
> > end
> >
> >
> > This experience might change your mind ...
> >
> > /Christoph
> >
> >
>
> Oops, I was (now, It tested it):
>
> class Proc
>    def *(other)
>      lambda{ |parms| self[other[*parms]] }
>    end
> end


That is nice - however

---
class Proc
   def *(other)
     lambda{ |parms| self[other[*parms]] }
   end
end


a = lambda {|x,|  x   }
b = lambda {|y,|  y }

c = b * a
p  a.arity, c.arity   # 1, -1
 ---

Anyway the example I had in mind is
more along the lines of

---
k =    35
a = lambda {|x,y|    [k + 2 * x, k +  3 * x]  }
b = lambda {|t,s|    t + s    }

c = b * c

c[1,1]  = = 75  # true
---

- this should work with essentially all  in and out going
arities.  Of course one can do it but it is more tedious
then you might think (which was my sole point) .


/Christoph