Ocaml has really clean syntax for a statically typed language. It is very clear what is going on the type system helps in debugging. Anyone here is commenting on the superficial and they even get that wrong
let f x = x *. x
let sqr_list l = List.map f l
let sqr_list l = List.map (fun x -> x *. x) l
let rec sqr_list = function
[] -> []
| x::xs -> ( x *. x ) :: sqr_list xs
let sqr_list l =
let ol = ref [] in
List.iter (fun x ->
ol := x :: !ol
) l
List.rev ol
let sqr_list l =
let ol = ref [] in
let len = length l in
for i = 0 to (len - 1) do
ol := (List.nth l (len - 1 - i)) :: !ol
done
ol
;;
So whatever. It all works and you can do the same thing multiple ways in multiple paradigms.