SML中的大整数集

约翰·西格

我在sml中遇到以下问题:我想使用IntListSet签名创建一个集合,int不想使用large int有没有什么办法解决这一问题?

谢谢您,等待您的答复。

马特

您可以使用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)

本文收集自互联网,转载请注明来源。

如有侵权,请联系[email protected] 删除。

编辑于
0

我来说两句

0条评论
登录后参与评论

相关文章