From: Calamitas Date: 2008-07-03T22:41:52+09:00 Subject: Re: thoughts on a more generic Array#partition function On Thu, Jul 3, 2008 at 3:16 PM, Rudi Cilibrasi wrote: > I have come to agree with your analysis. I think this one-line > expression you made is very good: As far as source-code brevity, > clarity, and correctness this expression you invented gets high marks > because there are no dangling outer variable etc and that is great. > But my small problem now is the extra code-block calls during runtime. > I guess there is one more code-block call per element in the > expression as written compared to npartition. So it is now down to a > > 1) small efficiency difference (probably npartition is slightly faster > but untested) > 2) small typing difference (Arrays versus hashses -- can go either way here) > 3) less requirements for group_by > > Thanks for the great input so far. Best regards, Maybe I'm being dense, but isn't the expression you assign to labels in your definition of npartition an implementation of group_by? If so, I would expect npartition to be slower than Ruby's group_by unless your implementation of group_by is more efficient than Ruby's. Peter