/ocaml-data-structures

Some data structures written in OCaml

Primary LanguageOCaml

ocaml-data-structures

I'm learning OCaml and re-learning some data structures.

Index

  • Stack (tests) - A simple stack implementation that pops, pushes, and peeks.
  • Trie (tests) - An implementation of a trie which can map strings to values in a performant way.
  • Setoid (tests) - Contract for setoids, which have an equivalence operation that allows these items to be placed into sets. The unit tests include an implementation to "uniquify" a list of "Person" setoids.
  • Functor (tests) - Haskell-type functors which implement an fmap function. Unit tests include implementations for Maybe and Either.
  • Algebra (tests) - Mechanism for representing algebraic instructions, with the ability to compute their derivatives.
  • Queue (tests) - An immutable queue, built from two Stacks.
  • Finite State Machine (tests) - Contracts for implementing a finite state machine (see unit tests for TrafficLight and Turnstile implementations). Built during @DavidKPiano's excellent ReactRally talk!
  • Wire (tests) - A mechanism which allows you to write procedures and populate their arguments later, based on a really interesting Advent of Code problem.

Development

# Build all the things
make

# Run the tests
make test