Am 05.07.2013 20:25, schrieb Love U Ruby:
> Hi,
>
> Can anyone give me one example to understand the functionality of
> Vector#map2(http://yard.ruby-doc.org/stdlib-2.0/Vector.html#collect2-instance_method).
> I understand the Vector#map.
>
> require 'matrix'
>
> a = [1, 2, 3, 4]
> m = Vector[*a] # => Vector[1, 2, 3, 4]
> m.map{|i| i * i } # => Vector[1, 4, 9, 16]

Shouldn't be too difficult to find out by looking at the source,
but anyway:

2.0.0p247 :007 > u = Vector[1, 2, 3]
  => Vector[1, 2, 3]
2.0.0p247 :008 > v = Vector[7, 8, 9]
  => Vector[7, 8, 9]
2.0.0p247 :009 >  u.collect2(v) {|e1, e2| e1*e2 }
  => [7, 16, 27]


Regards,
Marcus


-- 
<https://github.com/stomar/>