On Wed, 5 Jul 2006, Nasir Khan wrote:

> If I have two arrays a=[1,1,1,1] and b=[2,2,2,2] and I want to add each
> element up, something like -
>
> c = a plus b  => [3,3,3,3]
>
> One way I could think up is -
>
> irb(main):010:0> (0...a.length).collect{|k| a[k]+b[k]}
> => [3, 3, 3, 3]
>
> Is there a better/faster way?
>
> Thanks
> Nasir

harp:~ > cat a.rb
# gem install narray
require 'narray'

a = NArray.to_na [1,1,1,1]
b = NArray.to_na [2,2,2,2]

p a + b


harp:~ > ruby a.rb
NArray.int(4):
[ 3, 3, 3, 3 ]



-a
-- 
suffering increases your inner strength.  also, the wishing for suffering
makes the suffering disappear.
- h.h. the 14th dali lama