I start in ocaml and I would like to know how in a recursive function of type 'a list -> int ,
let rec int l =
match l with
| [] -> 0
| hd::tl -> 10
the list can be flattened only if necessary for example if [0;2;3;4] just returns the int and if [[0];2; [3;4]], then do -> [0;2;3;4] and then return the int.
Thank you in advance.
[[0];2;[3;4]]in OCaml? why not? - coredump'a listis a list of element of some type'a, but 2 and[2]have different types - coredump