Languages
Ocaml
Grammar

Quick start of Ocaml

OCaml’s grammar looks different than most mainstream languages. It uses just let and in keywords to express most language constructs. Below is a comparison table for new comers to start.

FeatureJavaOCaml
Start of block{let f a = let ..
End of block}in … in
Variable declarationint a = 1let a = 1 in …
Exampleint double(int a) {
int b = a * 2
return b
}
let double a =
let b = a * 2 in b
in
double 1
Last updated on July 31, 2022