let rec funli li k = match li with
| [x] -> if k==1 then Some(x) else None
| x::ll -> funli ll k-1;;
utop shows Error: This expression has type 'a option but an expression was expected of type int
I see no reason for it to expect int. Please help me understand what is happening in this code. I am new to OCaml.
funli ll (k-1)in thex:llarm. - Eli Sadoffk==1is invalid syntax. You wantk=1.==is not used to test equality in OCaml. - Eli Sadoff