Charles Hixson wrote:
> Martin DeMello wrote:
> 
>> ibotty <me / ibotty.net> wrote:
>>  
>>
>>> before i spent to many words describing something so simple:
>>>
>>> say, i have:
>>> a = [1,2,3] and b = [4,5,6]
>>> and i want to get another array, with c[ix] = a[ix] * b[ix].
>>> (i want to get c = [4,10,18])
>>>
>>> is there a builtin function in array.rb (that i have missed).
>>>   
>>
>>
>> Not quite, but for parallel traversing made easier
>>
>> a.zip(b).map {|i, j| i*j}
>>
>> martin
>>
>>
>>  
>>
> But isn't that the wrong answer?
> I thought that [1, 2, 3] * [4, 5, 6] would be:
> [ [4, 5, 6],
>  [8, 10, 12],
>  [12, 15, 18]
> ]  or some such (I might have reversed the arguments--and I don't think 
> it's commutative.  [Admittedly, it's been a few decades since I did such 
> math.]).  And if you meant the dot product rather than the cross 
> product, you would get a scalar.

I think this is what the original poster wanted. He doesn't
seem to be asking for a cross product OR a dot product as
far as I can tell, but just a nice idiomatic way of doing
a specific operation.

Hal