On Apr 29, 2007, at 1:17 PM, Brad Ediger wrote:

>   # Maps n-at-a-time (n = arity of given block) and collects the  
> results
>   def mapn(&b)
>     r = []
>     each_slice(b.arity) {|*args| r << b.call(*args) }
>     r
>   end

That's pretty darn clever.  You can collapse it to one line with  
inject() of course:

   def mapn(&b)
     enum_slice(b.arity).inject([]) {|r, args| r << b.call(*args) }
   end

James Edward Gray II