replaces remove_from by take which does not raise any exceptions

This commit is contained in:
Lesenechal Remi 2020-01-06 19:24:23 +01:00
parent 8ce4772ae4
commit a0a8f114c0
2 changed files with 4 additions and 4 deletions

View File

@ -27,7 +27,7 @@ let aggregate_and_compile = fun program form ->
let aggregate_and_compile_contract = fun (program : Types.program) name -> let aggregate_and_compile_contract = fun (program : Types.program) name ->
let%bind (exp, idx) = get_entry program name in 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) aggregate_and_compile program' (ContractForm exp)
let aggregate_and_compile_expression = fun program exp -> let aggregate_and_compile_expression = fun program exp ->

View File

@ -5,10 +5,10 @@ let rec remove n = function
| _ :: tl when n = 0 -> tl | _ :: tl when n = 0 -> tl
| hd :: tl -> hd :: remove (n - 1) tl | hd :: tl -> hd :: remove (n - 1) tl
let rec remove_from n = function let rec take n = function
| [] -> raise (Failure "List.remove_from") | [] -> []
| _ when n = 0 -> [] | _ when n = 0 -> []
| hd :: tl -> hd :: remove_from (n - 1) tl | hd :: tl -> hd :: take (n - 1) tl
let map ?(acc = []) f lst = let map ?(acc = []) f lst =
let rec aux acc f = function let rec aux acc f = function