哪些OCaml库可用于惰性列表处理?
-
05-07-2019 - |
题
哪些OCaml库提供了懒惰列表处理?我正在寻找这些方面的东西:
type 'a lazy_list = (*'*)
| Nil
| Cons of 'a * 'a lazy_list lazy_t
let from f =
let rec gen n =
lazy
(
match f n with
| Some x ->
Cons (x, gen (n + 1))
| None ->
Nil
)
in
gen 0
与 Stream
类型的集成以及回溯 Camlp4解析器的语法糖将会很好。
解决方案
Ocaml Batteries 有懒惰列表模块,查看 to_stream
函数。至于回溯,你可以查看camlp4的流解析器,因为你有一个Stream.t。
其他提示
此外,我的 OCaml网络应用环境<中有一个名为 Cf_seq
的惰性列表模块核心基金会。事实上,我写了一整套功能数据结构。这些都是根据2条款BSD许可证提供的。享受。
不隶属于 StackOverflow