我有这些类型:
type position = float * float
type node = position
Run Code Online (Sandbox Code Playgroud)
我已经编写了这些模块来创建我的 Map :
module MyMap =
struct
type t = node
let compare (a1,b1) (a2,b2) =
if a1 > a2 then 1
else if a1 < a2 then -1
else if b1 > b2 then 1
else if b1 < b2 then -1
else 0
end
module DistMap = Map.Make(MyMap)
Run Code Online (Sandbox Code Playgroud)
我曾尝试编写使用过的函数,iter但尝试以正确的语法表达我的想法没有成功。
我的目标是能够有一个函数,它将 Map 作为参数并返回一个包含最小元素及其键的元组。
谢谢。