Solutions to weekly exercises from my Functional Programming class (2024), written in OCaml. Each subdirectory is a self-contained Dune project.
Each project uses Dune:
cd <project-name>
dune build
dune runtest # if tests exist- list-interleave — Interleave three lists element-wise.
- list-interleave-reloaded — Interleave, append, and reverse revisited.
- list-module-basics — Reimplementing
hd,tl,length,append,rev,nth. - list-module-extras —
float_list,to_string,part_even,squaresum. - fold-puzzles — Exercises inferring behavior of
fold-based functions. - tail-recursion — Tail-recursive
fac,remove,partition. - ocamlfication — Translating imperative code into OCaml.
- vector3-basics — 3D vector operations on tuples.
- student-database — Insert, find-by-id, find-by-last-name over a student record list.
- student-queries — Removals, semester counts, and average grade queries.
- student-db-io — Serializing and deserializing the student database to disk.
- polynomial-eval-derive — Evaluate and differentiate polynomials given as coefficient lists.
- binary-search-tree — Abstract BST with
insert,remove,to_list. - polymorphic-tree — Polymorphic trees with user-supplied comparators.
- tree-crawler — A cursor-based command language (
Left,Right,Up,New,Delete,Push,Pop) walking and editing a binary tree. - infinite-lazy-trees — Lazy binary trees: layer trees, interval trees, Stern–Brocot rational trees, plus
top,map,find.
- lazy-lists — Lazy infinite lists: naturals, Fibonacci,
take,filter.
- rational-expr-eval — Evaluator for arithmetic expressions over rationals.
- expr-eval-with-lambdas — Extended interpreter with variables,
let, lambdas, application,if-then-else, and closures.
- peano-arithmetic — Peano naturals with
add,mul,pow,leq, plusint/natconversions. - lagrange-interpolation — Lagrange polynomial interpolation from sample points.
- minimum-spanning-tree — MST on a weighted edge-list graph.
- parallel-map —
par_app2andpar_mapusing OCaml domains.
- assoc-list-map — Map implemented as an association list.
- functor-map-modules — A tower of functors:
Printable,OrderedPrintable,Map, plus instantiations (IntIntMap,IntStringMap,BinaryTreeMap). - sparse-matrix-module — Sparse-matrix module built with functors.
- santa-knapsack — Present-factory simulation: reads wishlists and a catalogue, uses a knapsack-style selection algorithm, writes lists and letters.