def dot(a, b)
        unless a.size == b.size
          raise "Vectors must be the same length"
        end
  
        # Make element-by-element array of pairs
        (a.to_a).zip(b.to_a).inject(0) {|tot, pair| tot = tot + pair[0]*pair[1]}
      end
def dot(a, b)
        unless a.size == b.size
          raise "Vectors must be the same length"
        end
  
        # Make element-by-element array of pairs
        (a.to_a).zip(b.to_a).inject(0) {|tot, pair| tot = tot + pair[0]*pair[1]}
      end
Dot product of two n-element arrays