From: Martin DeMello Date: 2003-01-23T07:41:52+09:00 Subject: Re: Applying an operator to a list Travis Whitton wrote: > Hello all, I have a quick question: > Is it possible to create a Lisp style apply function with Ruby, and > would I have to use eval to create one? The function would work as > follows: > > [1, 2, 3].apply('+'.intern) # => 6 > [2, 3, 4].apply('*'.intern) # => 24 But all apply does in lisp is call a function and pass it the rest of the arguments as a list. The semantic definition of +(1,2,3) is an entirely separate issue. Along vaguely similar lines, take a look at http://www.rubygarden.org/ruby?AutoMap. martin