type 'a nested
= Cons
of 'a
* ('a
list) nested
| Nil
(*
let rec length x = match x with
| Nil -> 0
| Cons (_, tail) -> 1 + length tail
*)
let nest = Cons (1, Cons ([2;3;4], Cons ([[5;6];[7];[8;9]], Nil)))
let () =
dHlwZSAnYSBuZXN0ZWQKCT0gQ29ucyBvZiAnYSAqICgnYSBsaXN0KSBuZXN0ZWQKCXwgTmlsCigqCmxldCByZWMgbGVuZ3RoIHggPSBtYXRjaCB4IHdpdGgKCXwgTmlsIC0+IDAKCXwgQ29ucyAoXywgdGFpbCkgLT4gMSArIGxlbmd0aCB0YWlsCiopCmxldCBuZXN0ID0gQ29ucyAoMSwgQ29ucyAoWzI7Mzs0XSwgQ29ucyAoW1s1OzZdO1s3XTtbODs5XV0sIE5pbCkpKQoKbGV0ICgpID0KCXByaW50X2VuZGxpbmUgIkhlbGxvIgo=