From: Michael Neumann Date: 2004-08-03T04:45:10+09:00 Subject: Re: Request for two methods in Array class Mike Hall wrote: > Two small requests: > > 1. A new method, Array.combine (needs a better name for general use). > It takes entries from two (or many) arrays and combines them. > (like a combination of Array.zip, fetch, and map) > > For my use, I needed multiplication, but a block would be more general. > > a = [1,2,3] > b = [1,3,5] > a.combine(b) => [1,6,15] > > Or with a block: > > a.combine(b) {|x,y| x*y} > > The new method would replace this sequence: > > a.zip(b).map {|e| e[0]*e[1]} It's the same length: a.zip(b).map {|x,y| x*y} # vs. a.combine(b) {|x,y| x*y} But I must say, that I like the name combine a lot. Regards, Michael