+ def __sub__(self, other):
+ """
+ If other is a point, substract it from the vector self and return the
+ resulting point. If other is a vector, return the vector self - other.
+ """
+ if isinstance(other, (Point, Vector)):
+ coordinates = self._map2(other, operator.sub)
+ return other.__class__(coordinates)
+ return NotImplemented
+
+ def __neg__(self):
+ """
+ Return the vector -self.
+ """
+ coordinates = self._map(operator.neg)
+ return Vector(coordinates)
+
+ def __mul__(self, other):
+ """
+ Multiplies a Vector by a scalar value.
+ """
+ if not isinstance(other, numbers.Real):
+ return NotImplemented
+ coordinates = self._map(lambda coordinate: other * coordinate)
+ return Vector(coordinates)
+
+ __rmul__ = __mul__
+
+ def __truediv__(self, other):
+ """
+ Divide the vector by the specified scalar and returns the result as a
+ vector.
+ """
+ if not isinstance(other, numbers.Real):
+ return NotImplemented
+ coordinates = self._map(lambda coordinate: coordinate / other)
+ return Vector(coordinates)
+
+ def __eq__(self, other):
+ """
+ Test whether two vectors are equal.
+ """
+ return isinstance(other, Vector) and \
+ self._coordinates == other._coordinates
+