If you want to use a slightly different format, you can get your parser for free. Using the sexplib syntax extension, you can simply write:
type t = (int * int * int) list with sexp
and it will automatically detect two functions for you: sexp_of_t and t_of_sexp . Sexplib also provides several parsing features.
The specific syntax of s-expressions, however, is different. Your example will display:
((1 2 3) (1 2 5) (2 3 4))
yzzlr
source share