From 86402b208d4e925a15146a2541c937590320e9e0 Mon Sep 17 00:00:00 2001 From: Akshay Date: Sun, 8 Aug 2021 18:29:00 +0530 Subject: format --- src/utils.ml | 32 +++++++++++++++----------------- 1 file changed, 15 insertions(+), 17 deletions(-) (limited to 'src/utils.ml') diff --git a/src/utils.ml b/src/utils.ml index 62ae3a5..833c972 100644 --- a/src/utils.ml +++ b/src/utils.ml @@ -1,33 +1,31 @@ exception Empty_list + let fold fn = function - | [] -> raise Empty_list - | head :: tail -> List.fold_left fn head tail + | [] -> raise Empty_list + | head :: tail -> List.fold_left fn head tail let list_min ls = fold Stdlib.min ls + let list_max ls = fold Stdlib.max ls -let rec repeat n a = - if n <= 0 - then [] - else a :: repeat (n - 1) a +let rec repeat n a = if n <= 0 then [] else a :: repeat (n - 1) a -let empty ls = (ls = []) +let empty ls = ls = [] let rec zip l1 l2 = - match (l1, l2) with - | ([], _) -> [] - | (_, []) -> [] - | (h1 :: t1, h2 :: t2) -> (h1, h2) :: zip t1 t2 + match (l1, l2) with + | [], _ -> [] + | _, [] -> [] + | h1 :: t1, h2 :: t2 -> (h1, h2) :: zip t1 t2 let rec transpose = function - | [] :: _ -> [] - | ls -> List.(map hd ls) :: transpose List.(map tl ls) + | [] :: _ -> [] + | ls -> List.(map hd ls) :: transpose List.(map tl ls) let flip f a b = f b a let rot_right ls = List.(rev ls |> transpose) -let rot_left ls = List.(transpose ls |> rev) -let saturating_sub b a = - if a < b then 0 - else a - b +let rot_left ls = List.(transpose ls |> rev) + +let saturating_sub b a = if a < b then 0 else a - b -- cgit v1.2.3