Created
January 6, 2018 04:31
-
-
Save ayazhafiz/fec1b5d60fc4405335ff425e0f8feb2e to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fn cost(points: &[[f64; 2]], center: &[f64; 2]) -> f64 { | |
points.iter().fold(0., |net, point| { | |
let cost = ( | |
(center[0] - point[0]).powi(2) // `x` coordinates | |
+ (center[1] - point[1]).powi(2) // `y` coordinates | |
).sqrt(); | |
net + cost | |
}) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment