A scala version of k-means.