OCaml "list" with constant addition front and back?

I am new to OCaml and am curious if there is an (standard) data structure in OCaml equivalent to

http://hackage.haskell.org/package/containers-0.2.0.1/docs/Data-Sequence.html

which provides O (1) add and add operations?

+4
source share
1 answer

I believe this is commonly called deque.

Here's the implementation implemented in OCaml Batteries:

http://ocaml-batteries-team.imtqy.com/batteries-included/hdoc/BatDeque.html

It looks like something similar in Jane Street Core:

https://ocaml.janestreet.com/ocaml-core/111.17.00/doc/core/#Dequeue

These (I would require) are the two most widely used OCaml core libraries.

+7
source

All Articles