Want to learn and master OCaml?

Join Exercism’s OCaml Track for access to 49 exercises with automatic analysis of your code and personal mentoring, all 100% free.

Explore exercises

About OCaml

OCaml is an industrial strength programming language supporting functional, imperative and object-oriented styles - but don't worry if you're not familiar with these, as it's used as a teaching language by a lot of institutions (including Cornell and Princeton).

One of the best features of OCaml is the rich and powerful type system - this is useful to catch some mistakes early on saving developers a huge amount of frustration. Also, type inference relieves developers from having to specify types in the code - the compiler will work these out for you!

It's used by Facebook (for static code analysis with Infer) and Jane Street (for providing strong guarantees for their internal trading systems), and has influenced the F# functional programming language and ReasonML.

let rec fib = function
  | 0 -> 1
  | 1 -> 1
  | n -> fib (n - 1) + fib (n - 2)

49 coding exercises for OCaml on Exercism. From Acronym to Meetup.


Get better at programming through fun, rewarding coding exercises that test your understanding of concepts with Exercism.

See all OCaml exercises on Exercism

Key Features of OCaml


OCaml

Algebraic data types

Powerful tools to define and manipulate complex data structures with ease.

Immutable programming

No need for destructive updates to data structures or accidental mutation.

Static typing

Increased performance and reduced runtime errors.

First class functions

Can be passed like any value, used as arguments, and returned from other functions.

Type inference

Automatic inference makes the code less verbose and developers more efficient.

Parametric polymorphism

Construct abstractions that work across data types, like generics in Java and templates in C++.

Get mentored the OCaml way

Every language has its own way of doing things. OCaml is no different. Our mentors will help you learn to think like a OCaml developer and how to write idiomatic code in OCaml. Once you've solved an exercise, submit it to our volunteer team, and they'll give you hints, ideas, and feedback on how to make it feel more like what you'd normally see in OCaml - they'll help you discover the things you don't know that you don't know.

Learn more about mentoring

Community-sourced OCaml exercises

The OCaml track on Exercism has 49 exercises to help you write better code. Discover new exercises as you progress and get engrossed in learning new concepts and improving the way you currently write.

See all OCaml exercises
OCaml

Get started with the OCaml track

The best part, it’s 100% free for everyone.