From: Rha7 Date: 2009-06-08T05:55:08+09:00 Subject: Re: adding, multiplying array Haris Bogdanovi� wrote: > Hi. > > I want to multply all elements of two arrays and add that to all elements of > the third array like this: > > c+=a*b > > c=[1,1,1] > a=[2,2,2] > b=[3,3,3] > > c=[7,7,7] # (1+2*3)=7 > > I tried (found on google): > > a.zip(b).map {|i,j| i*j} (don't really know how that works) > > and how to add that to c array ? > > Thanks > > require 'pp' d=[] a.each_with_index{|o, i| d[i] = a[i] + b[i] * c[i] }; pp d