From: Aleksei Guzev Date: 2002-11-18T13:28:11+09:00 Subject: Re: Ruby equivalent to Python's map()? "Pe�a, Botp" wrote in message news:20021116175944.16A7C781C0@proxy-dmz.delmonte-phil.com... > Hi Aleksei [mailto:aleksei.guzev@bigfoot.com]: > > You wrote: > > ###################################################### > > > > module Enumerable > > def collectm(*args,&proc) > > result = [] > > each_with_index{|e,i| res << yield(e,*args.collect{|f| f[i]})} > ^^^^^^ > shouldn't be result? > [snipped some] > > > > [1,2,3].collectm([18,12,16],[4,5,6]) {|a,b,c| b/a+c} > > # results in [10,11,12] > > I get [22, 11, 11] :-) > > Anyway, you have very helpful code. Can you post it in wiki? > > Kind regards, > -botp > > khe,khe. A little mistype, I hope everyone does see it;) [1,2,3].collectm([6,12,18],[4,5,6]){|a,b,c| b/a+c} will yield the correct result.