######################################################

module Enumerable
    def collectm(*args,&proc)
        result = []
        each_with_index{|e,i| res << yield(e,*args.collect{|f| f[i]})}
        return result
    end
end

######################################################


# some examples

s1 = ['a','b','c']
s2 = ['d','e','f']
s3 = ['g','h','i']

s1.collectm(s2){|e1,e2| [e1,e2]}
# results in [['a','d'],['b','e'],['c','f']]

s1.collectm(s2,s3){|e1,e2,e3| [e1,e2,e3]}
# results in [['a','d','g'],['b','e','h'],['c','f','i']]

s1.collectm(s2){|e1,e2| e1+e2}
# results in ['ad','be','cf']

[1,2,3].collectm([18,12,16],[4,5,6]) {|a,b,c| b/a+c}
# results in [10,11,12]