What OCaml libraries are there for lazy list handling?

…衆ロ難τιáo~ 提交于 2019-12-12 13:39:59

问题


What OCaml libraries are out there that provide lazy list handling? I am looking for something along these lines:

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

Integration with the Stream type and syntactic sugar for backtracking Camlp4 parsers would be nice.


回答1:


Ocaml Batteries has a lazy list module, check out the to_stream function. As for backtracking, you can look into camlp4's stream parsers now that you have a Stream.t .




回答2:


Also, there is a lazy list module called Cf_seq in my OCaml Network Application Environment Core Foundation. In fact, I wrote a whole passle of functional data structures. It's all available under a 2-clause BSD license. Enjoy.

Update: the code has been renamed "Oni" and it's now hosted at BitBucket. You can also use the GODI package for it.



来源:https://stackoverflow.com/questions/1403641/what-ocaml-libraries-are-there-for-lazy-list-handling

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!