在 OCaml 中将哈希表转换为对(键,值)列表
OCaml 中有没有办法将哈希表转换为(键,对)值列表?
我知道,给定哈希表 ht
我们可以
BatList.of_enum (BatHashtbl.enum ht)
使用电池库。这会将表转换为枚举,然后将枚举转换为列表。但我正在寻找一种不使用电池库的解决方案。在 标准 OCaml Hashtbl 模块 中似乎没有是一种将对提取为列表的方法或组合其功能以实现此目的的方法。有什么建议吗?
Is there a way of converting a hash table into a list of (key,pair) values in OCaml?
I'm aware that, given a hash table ht
we can do
BatList.of_enum (BatHashtbl.enum ht)
using the batteries library. This would convert the table to an enumeration and then convert the enum to a list. But I'm looking for a solution that doesn't use the Batteries Library. In the standard OCaml Hashtbl Module there doesn't seem to be a way of extracting the pairs as a list or a way of combining its functions to achieve this purpose. Any suggestions?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
当然有!
所以,使用:
Of couse there is!
So, use: