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.
Feature | Java | OCaml |
---|---|---|
Start of block | { | let f a = let .. |
End of block | } | in … in |
Variable declaration | int a = 1 | let a = 1 in … |
Example | int 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