From: Charles Mills Date: 2004-08-03T11:32:35+09:00 Subject: Re: Request for two methods in Array class On Aug 2, 2004, at 6:51 PM, Charles Mills wrote: > On Aug 2, 2004, at 1:21 PM, Ara.T.Howard wrote: > >> On Tue, 3 Aug 2004, Michael Neumann wrote: >> >>> It's the same length: >>> a.zip(b).map {|x,y| x*y} >>> # vs. >>> a.combine(b) {|x,y| x*y} >> >> but one less object creation >> >>> But I must say, that I like the name combine a lot. >> >> ditto. > Seems like a good idea. After reading the chapter of Meyers book > Lothar sent, the idea seems even better. > Another name idea is collect_wtih > c = a.collect_with(b) { |x,y| x*y } > a.collect_with!(b) { |x,y| x*y } # looks bad? > d = a.collect_with(b, c) { |x,y,z| x*y*z } # multiple params would be > useful > Looks like this has been talked about by others: http://www.ai.mit.edu/~gregs/ll1-discuss-archive-html/msg03386.html http://blade.nagaokaut.ac.jp/cgi-bin/scat.rb/ruby/ruby-list/29671 still seems useful to me though c = a.collect_with(keys) { ... } > -Charlie > >> >> -a >> -- >> ====================================================================== >> ========= >> | EMAIL :: Ara [dot] T [dot] Howard [at] noaa [dot] gov >> | PHONE :: 303.497.6469 >> | A flower falls, even though we love it; >> | and a weed grows, even though we do not love it. | --Dogen >> ====================================================================== >> ========= >> > >