From: Christoph Date: 2002-09-24T22:40:43+09:00 Subject: Re: are functions/methods "first class objects"? "Christian Szegedy" .... > > 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 > > --- > > I don't understand your example. I guess, you wanted to > write > c = b*a Yes - sorry ... > but what do you expect to be the result of the composition > of a two variable function and a two variable function? > A two variable function returning a one variable function? > But this does not match your example... > Perhaps you wanted to write c[1,1][k] == 75 ? No I really mend c[1,1] == 75 # in a pestrian way --- k = 35 a = lambda {|x,y| [k + 2 * x, k + 3 * x] } b = lambda {|t,s| t + s } c = lambda {|_t,_s| b[*a[_t,_s]] } p c[1,1] # 75 --- > > > - 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) . > > OK, I admit that in this generality it is not so simple in > Ruby as in (***)ML. > > Now, let us be honest, is it so important? I do a lot of > meta-programming, but I have never encountered a situation > requiring such a high level approach. I guess this (and other functional ``deficiencies'') is (are) not important since Ruby is probably more of an ``functionally enhanced imperative language'' - so any potential weakness of Rubys functional side are well taken care of by its strong imperative meta features. /Christoph