Spark Experts,
I've got a list of points: List[(Float, Float)]) that represent (x,y)
coordinate pairs and need to sum the distance. It's easy enough to compute the
distance:
case class Point(x: Float, y: Float) {
def distance(other: Point): Float =
sqrt(pow(x - other.x, 2) + pow(y - other.y, 2)).toFloat
}
(in this case I create a 'Point' class, but the maths are the same).
What I can't figure out is the 'right' way to sum distances between all the
points. I can make this work by traversing the list with a for loop and using
indices, but this doesn't seem right.
Anyone know a clever way to process List[(Float, Float)]) in a pairwise fashion?
Regards,
- Steve