type 'a nested = Cons of 'a * ('a list) nested | Nil let rec len x = match x with | Nil -> 0 | Cons (_, tail) -> 1 + len tail let nest = Cons (1, Cons ([2;3;4], Cons ([[5;6];[7];[8;9]], Nil))) let () = print_int (len nest)
Standard input is empty
File "prog.ml", line 7, characters 29-33: Error: This expression has type 'a list nested but an expression was expected of type 'a nested The type variable 'a occurs inside 'a list
Standard output is empty
The brand new service which powers Ideone!
Widget for compiling and running the source code in a web browser!