What this mean let ..... in let ....in

HI
i am have a problem of understanding what let… in mean in the ocmal code. like this code below
in aux 0 list. can we remove in.

let length list =
let rec aux n = function
| [] -> n
| _::t -> aux (n+1) t
in aux 0 list;;

thank you

Please read http://ocaml.org/learn/tutorials/structure_of_ocaml_programs.html and https://realworldocaml.org/v1/en/html/variables-and-functions.html The construct let v = e1 in e2 defines the variable v which is local to the expression e2. The expression e1 may be a function.

2 Likes