In OCaml from the Very Beginning John Whitington takes a no-prerequisites approach to teaching a modern general-purpose programming language. Each small, self-contained chapter introduces a new topic, building until the reader can write quite substantial programs. There are plenty of questions and, crucially, worked answers and hints.
OCaml from the Very Beginning will appeal both to new programmers, and experienced programmers eager to explore functional languages such as OCaml. It is suitable both for formal use within an undergraduate or graduate curriculum, and for the interested amateur.
John Whitington founded a company which builds software for electronic document processing. He studied, and taught, Computer Science at Queens’ College, Cambridge. His books include the textbooks PDF Explained (O'Reilly, 2012), OCaml from the Very Beginning (Coherent, 2013), and Haskell from the Very Beginning (Coherent, 2019) and the Popular Science book A Machine Made this Book: Ten Sketches of Computer Science (Coherent, 2016).
Reminds me during my late first year at college where I reset the programming knowledge acquired in the high school that was used for competitive programming and start over from the computational thinking through functional notation and LISP. that was kind of fun.
Finally. A book teaching FP. I tried other languages (Scala, Haskell) and their recommended books but they assumed too much. I know programming very well with many years. But FP eluded me after investing way too much time on recommended books. I didn't know OCAML but got up to speed very quickly; it's almost an ideal language for learning FP because you don't need to know much to do the exercises. I'd say if you are reading another language book and getting nowhere, consider this one, even if you didn't think you wanted to use OCAML. You don't really need to spend that much time to get up to speed; I pretty much was doing FP right away in this new language. Other "recommended books" were not the path for me. Real World OCAML is not a book for newcomers to OCAML or to FP. Functional Programming in Scala is definitely not for beginners in FP. This one, however fulfils both categories. I'd say one thing tho: if you have 20 exercises, all on recursion, maybe do 5 of them, then move on. Why? Because you need to learn fp by moving forward, not how the [already existing] standard library was built. Authors need to spend less time on theoretical things like how you can build library functions yourself, and spend more time USING existing library functions of the same name, solving real problems, putting it all together to build software, not just parts.
OCaml-curious? This quick and easy read gives you a taste of this fascinating programming language.
Note that the Kindle edition has some wonky formatting whenever data types are shown that the publisher should have noticed, but otherwise doesn't detract from the substance of the book itself.