我打算Map在 Ocaml 中练习使用。
我发现 of 的用法与,等Map有很大不同。ListArray
我知道这是functor我还没有学过的应用。但没关系。
这是我的IntMap
module IntMap = Map.Make(struct type t = int let compare = compare end)
所以,现在我可以使用IntMapto addbyIntMap.add x y map等,对吧?
我有几个问题:
- 如何控制中的
value类型map? - 如果我想要 my 的别名类型,我
IntMap应该怎么做?我可以做type 'a my_type = 'a list,但要怎么做map呢? - 我发现这
IntMap很像List,而且他们俩实际上都是modules。但是List有一个类型的list,那map呢?