I just began to learn Ocaml recently and now just started to practice some codes. In this case, I tried to find a maximum number in a list but it keeps return me an error message.
let max: int list -> int
= fun lst ->
match lst with
|[] -> 0
|h::[] -> h
|h::t -> let a = max t in
if h < a then h
else
a;;
Ocaml keeps saying:
Error: This expression has type int list -> int list but an expression was expected of type int.
I don't understand why a is an int list though I claimed it as a max t which is a function that makes int list into int... Thanks for yout help.