Skip to content
AdemYahmadiPublic

About

My solutions to 27 OCaml functional programming exercises: recursion, trees, lazy evaluation, interpreters, modules & functors, parallelism.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

4 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

OCaml Exercises

Solutions to weekly exercises from my Functional Programming class (2024), written in OCaml. Each subdirectory is a self-contained Dune project.

Building a project

Each project uses Dune:

cd <project-name>
dune build
dune runtest        # if tests exist

Projects

Lists & Recursion

  • 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.

Records & Data

  • 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.

Trees

  • 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 Evaluation

  • lazy-lists — Lazy infinite lists: naturals, Fibonacci, take, filter.

Expressions & Interpreters

  • 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.

Numerics

  • peano-arithmetic — Peano naturals with add, mul, pow, leq, plus int/nat conversions.
  • lagrange-interpolation — Lagrange polynomial interpolation from sample points.
  • minimum-spanning-tree — MST on a weighted edge-list graph.
  • parallel-map — par_app2 and par_map using OCaml domains.

Modules & Functors

  • 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.

Applications

  • santa-knapsack — Present-factory simulation: reads wishlists and a catalogue, uses a knapsack-style selection algorithm, writes lists and letters.

About

My solutions to 27 OCaml functional programming exercises: recursion, trees, lazy evaluation, interpreters, modules & functors, parallelism.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Contributors

Languages