在 F# 中,假设
game: (int*int) list
我想计算每个元组维度的 minx、maxx、miny、maxy 最小值和最大值。
这段代码有效,但似乎有点笨拙:
let minX (game: (int*int) list) = game |> List.map (fun (x,y) -> x) |> Seq.min
let maxX (game: (int*int) list) = game |> List.map (fun (x,y) -> x) |> Seq.max
let minY (game: (int*int) list) = game |> List.map (fun (x,y) -> y) |> Seq.min
let maxY (game: (int*int) list) = game |> List.map (fun (x,y) -> y) |> Seq.max
有什么改进的提示吗?