From 813502532b0f5a725ea2e71d26d89f5aed7cef79 Mon Sep 17 00:00:00 2001 From: Simon Forman Date: Sat, 24 Sep 2022 13:13:44 -0700 Subject: [PATCH] Autoformat. --- implementations/Ocaml/helloworld/bin/main.ml | 28 +++++++++++++++------------- 1 file changed, 15 insertions(+), 13 deletions(-) diff --git a/implementations/Ocaml/helloworld/bin/main.ml b/implementations/Ocaml/helloworld/bin/main.ml index d75f4cb..08115da 100644 --- a/implementations/Ocaml/helloworld/bin/main.ml +++ b/implementations/Ocaml/helloworld/bin/main.ml @@ -169,26 +169,28 @@ let joy stack expression dictionary = (stack @ expression, dictionary) exception StackUnderflow of string exception ValueError of string -let pop_int : joy_list -> int * joy_list = fun stack -> +let pop_int : joy_list -> int * joy_list = + fun stack -> match stack with | [] -> raise (StackUnderflow "Not enough values on stack.") - | head :: tail -> - match head with - | JoyInt i -> (i, tail) - | _ -> raise (ValueError "Not an integer.") + | head :: tail -> ( + match head with + | JoyInt i -> (i, tail) + | _ -> raise (ValueError "Not an integer.")) let joy_eval sym stack expression dictionary = match sym with | "+" -> - let (a, s0) = pop_int(stack) in - let (b, s1) = pop_int(s0) in - ((JoyInt (a + b) :: s1), expression, dictionary) + let a, s0 = pop_int stack in + let b, s1 = pop_int s0 in + (JoyInt (a + b) :: s1, expression, dictionary) | "-" -> - let (a, s0) = pop_int(stack) in - let (b, s1) = pop_int(s0) in - ((JoyInt (b - a) :: s1), expression, dictionary) - | _ -> let func = dictionary sym in - (stack, (func @ expression), dictionary) + let a, s0 = pop_int stack in + let b, s1 = pop_int s0 in + (JoyInt (b - a) :: s1, expression, dictionary) + | _ -> + let func = dictionary sym in + (stack, func @ expression, dictionary) let rec joy : joy_list -> joy_list -> joy_dict -> joy_list * joy_dict = fun stack expression dictionary -> -- 2.11.0