OCaml by Example?

Is there an “OCaml by Example” book/tutorial somewhere?

I’m familiar with Rust/Clojure and want to learn OCaml syntax by typing lots of OCaml examples, trying to run the code, and fixing any typos.

See 99 (solved) problems. The official OCaml manual has also a lot of examples,

1 Like

There are a LOT of examples on RosettaCode:

1 Like

My original question was not well written.

I’m looking for the OCaml equiv of https://doc.rust-lang.org/rust-by-example/

something that intends to explain OCaml syntax / features one by one, by examples.

Maybe you’re looking for Yaron Minsky’s Real World Ocaml book?

A bit OT, but please be careful with RosettaCode. It contains plain wrong information about OCaml which hasn’t been corrected for years.

If anyone on this forum has an account there please correct it, there’s a discussion about this here (see my answer).


Having a cursory look at the rust book you have provided I think the closest you can get to this is John Whitington’s series of books starting with OCaml from the Very Beginning.

His books are the best ones I ever read about OCaml.

1 Like