大型Int设置为sml

时间:2015-06-06 21:39:37

标签: sml smlnj

我在 sml 中遇到以下问题: 我想使用IntListSet签名创建一个集合,而不是int我要使用large int。 有什么方法可以解决这个问题吗?

谢谢你, 等待你的回答

1 个答案:

答案 0 :(得分:3)

您可以使用ListSetFn仿函数。从文档中,您会发现:

functor ListSetFn (ORD_KEY) : ORD_SET

这表示ListSetFn是一个带有满足ORD_KEY签名的结构的仿函数,您可以在文档中找到:

type ord_key
val compare : (ord_key * ord_key) -> order 

基本上,您需要创建一个满足ORD_KEY签名的结构,例如:

structure LargeIntKey : ORD_KEY = 
struct 
  type ord_key = LargeInt.int 
  val compare = LargeInt.compare
end

然后您可以通过执行以下操作创建LargeInt仿函数的ListSetFn实例:

 structure LargeIntSet = ListSetFn(LargeIntKey)