From a0a8f114c0ed599fbed8aa169e623dc1d23e40e3 Mon Sep 17 00:00:00 2001 From: Lesenechal Remi Date: Mon, 6 Jan 2020 19:24:23 +0100 Subject: [PATCH] replaces remove_from by take which does not raise any exceptions --- src/main/compile/of_mini_c.ml | 2 +- vendors/ligo-utils/simple-utils/x_list.ml | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/main/compile/of_mini_c.ml b/src/main/compile/of_mini_c.ml index fb2945265..be27f0f6b 100644 --- a/src/main/compile/of_mini_c.ml +++ b/src/main/compile/of_mini_c.ml @@ -27,7 +27,7 @@ let aggregate_and_compile = fun program form -> let aggregate_and_compile_contract = fun (program : Types.program) name -> let%bind (exp, idx) = get_entry program name in - let program' = List.remove_from idx program in + let program' = List.take idx program in aggregate_and_compile program' (ContractForm exp) let aggregate_and_compile_expression = fun program exp -> diff --git a/vendors/ligo-utils/simple-utils/x_list.ml b/vendors/ligo-utils/simple-utils/x_list.ml index 8541c4614..4b74c0261 100644 --- a/vendors/ligo-utils/simple-utils/x_list.ml +++ b/vendors/ligo-utils/simple-utils/x_list.ml @@ -5,10 +5,10 @@ let rec remove n = function | _ :: tl when n = 0 -> tl | hd :: tl -> hd :: remove (n - 1) tl -let rec remove_from n = function - | [] -> raise (Failure "List.remove_from") +let rec take n = function + | [] -> [] | _ when n = 0 -> [] - | hd :: tl -> hd :: remove_from (n - 1) tl + | hd :: tl -> hd :: take (n - 1) tl let map ?(acc = []) f lst = let rec aux acc f = function