Ocaml FTW!

This commit is contained in:
Simon Forman
2022-09-23 08:37:04 -07:00
parent 8cb04fc72d
commit c76ae9979d
63 changed files with 324 additions and 0 deletions
@@ -0,0 +1,4 @@
(executable
(public_name helloworld)
(name main)
(libraries helloworld))
@@ -0,0 +1,17 @@
type joy_type =
| JoySymbol of string
| JoyTrue
| JoyFalse
| JoyInt of int
| JoyList of joy_type list
type joy_list = joy_type list
let joy_true = JoyTrue
let joy_false = JoyFalse
let j_loop = JoySymbol "loop"
let empty_list = JoyList []
let zero = JoyInt 0
let dummy = [ joy_true; joy_false; j_loop; zero ]
let list_get jt = match jt with JoyList el -> el | _ -> []
let () = print_endline "Hello, World!"
@@ -0,0 +1,4 @@
(executable
(public_name helloworld)
(name main)
(libraries helloworld))
Binary file not shown.
@@ -0,0 +1,24 @@
type joy_type =
| JoySymbol of string
| JoyTrue
| JoyFalse
| JoyInt of int
| JoyList of joy_type list
(* type joy_list = joy_type list *)
let joy_true = JoyTrue
let joy_false = JoyFalse
let j_loop = JoySymbol "loop"
let zero = JoyInt 0
let dummy = JoyList [ joy_true; joy_false; j_loop; zero ]
let rec joy_to_string jt =
match jt with
| JoySymbol sym -> sym
| JoyTrue -> "true"
| JoyFalse -> "false"
| JoyInt i -> string_of_int i
| JoyList el -> "[" ^ (String.concat " " (List.map joy_to_string el)) ^ "]";;
let () = print_endline (joy_to_string dummy)
@@ -0,0 +1 @@
(* Auto-generated by Dune *)