Learn OCaml the functional way: from printing and let bindings to pattern matching, recursion, lists and maps, ending with a small receipt program.
8 lessons, 16 exercises. Runs OCaml 5.4.
Not started
Hello, output
Print text with print_endline, print_string and Printf, write comments, and see how an OCaml program runs.
Values and variables
Give names to values with let, meet OCaml's basic types, and learn why bindings never change.
Reading input and arithmetic
Read lines from standard input, turn text into numbers, and calculate with int and float operators.
Making decisions
Choose between values with if expressions and match, using comparison and boolean operators.
Loops and recursion
Repeat work with for loops and, the OCaml way, with recursive functions that stop when they are done.
Functions
Define functions with parameters and return values, read their types, and see how scope keeps names local.
Lists and maps
Store many values in lists, transform them with map, filter and fold, and look things up by key with Map.
Strings and a small project
Slice, split, join and transform strings, then combine everything so far into a receipt printer.
Your progress is saved in this browser. Sign in to keep it on every device.