RosettaCodeData/Task/Closest-pair-problem/F-Sharp/closest-pair-problem-1.fs
2023-07-01 13:44:08 -04:00

6 lines
209 B
FSharp

let closest_pairs (xys: Point []) =
let n = xys.Length
seq { for i in 0..n-2 do
for j in i+1..n-1 do
yield xys.[i], xys.[j] }
|> Seq.minBy (fun (p0, p1) -> (p1 - p0).LengthSquared)