|
|
|
|
|
by srean
4456 days ago
|
|
Since there has been a resurgence of interest in OCaml on HN, some may be curious to see how a production quality Btree implementation looks like in OCaml. Algebraic data types, make it particularly convenient for these sorts of things. For comparison one may contrast it with an implementation in a language that does not have algebraic types, C++ for example. So glad Rust chose to have them. Here is a Btree implementation from the mirage project [1]
https://github.com/cgreenhalgh/ocaml-btree/blob/master/lib/b... EDIT: removed link to binary tree after kerneis pointed it out. [1] http://www.openmirage.org/ |
|
Despite the name, I'm afraid this is a simple binary tree implementation, not a BTree:
type 'a tree = Empty | Node of('a * 'a tree * 'a tree);;
Obviously the author didn't know what he was doing (the intended scope was very large, AVL, BTrees, etc. but he stopped after committing this single file).