So that's mutual recursion in Ocaml?

I like it.  Just change "let" to "and" and you're good-to-go.
This commit is contained in:
Simon Forman 2022-09-23 08:59:06 -07:00
parent d717b594c4
commit 4d7ed83238
1 changed files with 3 additions and 1 deletions

View File

@ -19,6 +19,8 @@ let rec joy_to_string jt =
| JoyTrue -> "true" | JoyTrue -> "true"
| JoyFalse -> "false" | JoyFalse -> "false"
| JoyInt i -> string_of_int i | JoyInt i -> string_of_int i
| JoyList el -> "[" ^ String.concat " " (List.map joy_to_string el) ^ "]" | JoyList el -> "[" ^ expression_to_joy el ^ "]"
and expression_to_joy el = String.concat " " (List.map joy_to_string el)
let () = print_endline (joy_to_string dummy) let () = print_endline (joy_to_string dummy)