Closest-pair problem: Difference between revisions

m
fix Swift version
m (→‎{{header|REXX}}: added whitespace.)
m (fix Swift version)
Line 4,337:
guard xP.count > 3 else { return xP.closestPairBruteForce() }
let xlhalf = Array(xP.prefix(xP.count / 2))
let xrxl = Array(xP[.suffix(xP.count / 2)<half])
let xmxr = Array(xP[half.last!.x.])
let xm = xl.last!.x
let (yl, yr) = yP.reduce(into: ([Element](), [Element]()), {cur, el in
if el.x > xm {
Line 4,384 ⟶ 4,385:
guard count != 2 else { return (minDistance, closestPoints) }
for i in 0..<count-1 {
for j in i+1..<count {
let (iIndex, jIndex) = (index(startIndex, offsetBy: i), index(startIndex, offsetBy: j))