From: Robert Klemme Date: 2010-09-07T00:22:32+09:00 Subject: Re: Odd functional programming question On Mon, Sep 6, 2010 at 5:07 PM, Peter Hickman wrote: > On 6 September 2010 15:52, Robert Klemme wrote: >> Actually I'd say _this_ definition of X is completely superfluous >> since it does not add anything to #send and so only helps obfuscate >> code and slows down execution. > > It was just a dummy method to get a feel how the code would be used. > What I am using it for is a method to compare two pieces of data with > a variety of optional preprocessing. This way I can put the > preprocessing (of which there could be several variants) in an array, > as [ :gsub, /[aeiouy/, '_' ] etc, and iterate over the data and the > preprocessors and get the fitness scores out of the X method. > > I will mean that I have one X method rather than X1, X2 ... Xn which > are all just minor variations on X. Where do you take the sequence of operations from? Maybe it's simpler (but certainly more efficient) to just load a Ruby file and execute the code fetched from there. Or use evil #eval to compile the code for later execution. You could then store it in a lambda and execute it from there. Kind regards robert -- remember.guy do |as, often| as.you_can - without end http://blog.rubybestpractices.com/