From ac9f8054469a30bfd52acff175e5432254f3fadb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?L=C3=A9onard=20G=C3=A9rard?= Date: Tue, 14 Dec 2010 18:31:09 +0100 Subject: [PATCH] Refactoring. --- compiler/heptagon/analysis/typing.ml | 8 ++++---- compiler/utilities/misc.ml | 4 ++-- compiler/utilities/misc.mli | 6 +++--- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/compiler/heptagon/analysis/typing.ml b/compiler/heptagon/analysis/typing.ml index 64c5bd7..43b277b 100644 --- a/compiler/heptagon/analysis/typing.ml +++ b/compiler/heptagon/analysis/typing.ml @@ -753,7 +753,7 @@ and typing_iterator const_env h | Ifold -> let args_ty_list = - incomplete_map (fun ty -> Tarray (ty, n)) args_ty_list in + map_butlast (fun ty -> Tarray (ty, n)) args_ty_list in let typed_e_list = typing_args const_env h args_ty_list e_list in (*check accumulator type matches in input and output*) @@ -769,7 +769,7 @@ and typing_iterator const_env h ( try unify idx_ty (Tid Initial.pint) with TypingError _ -> raise (TypingError (Efoldi_bad_args idx_ty))); let args_ty_list = - incomplete_map (fun ty -> Tarray (ty, n)) (args_ty_list@[acc_ty]) in + map_butlast (fun ty -> Tarray (ty, n)) (args_ty_list@[acc_ty]) in let typed_e_list = typing_args const_env h args_ty_list e_list in (*check accumulator type matches in input and output*) @@ -780,9 +780,9 @@ and typing_iterator const_env h | Imapfold -> let args_ty_list = - incomplete_map (fun ty -> Tarray (ty, n)) args_ty_list in + map_butlast (fun ty -> Tarray (ty, n)) args_ty_list in let result_ty_list = - incomplete_map (fun ty -> Tarray (ty, n)) result_ty_list in + map_butlast (fun ty -> Tarray (ty, n)) result_ty_list in let typed_e_list = typing_args const_env h args_ty_list e_list in (*check accumulator type matches in input and output*) diff --git a/compiler/utilities/misc.ml b/compiler/utilities/misc.ml index e3ca75e..7e809cd 100644 --- a/compiler/utilities/misc.ml +++ b/compiler/utilities/misc.ml @@ -52,11 +52,11 @@ let unique l = List.iter (fun i -> Hashtbl.replace tbl i ()) l; Hashtbl.fold (fun key _ accu -> key :: accu) tbl [] -let rec incomplete_map f l = +let rec map_butlast f l = match l with | [] -> [] | [a] -> [a] - | a::l -> (f a)::(incomplete_map f l) + | a::l -> (f a)::(map_butlast f l) let rec last_element l = match l with diff --git a/compiler/utilities/misc.mli b/compiler/utilities/misc.mli index d8583ab..6af533c 100644 --- a/compiler/utilities/misc.mli +++ b/compiler/utilities/misc.mli @@ -23,9 +23,9 @@ val reset_symbol : unit -> unit (** [unique l] returns the [l] list without duplicates. O([length l]). *) val unique : 'a list -> 'a list -(** [incomplete_map f l] applies f to all the elements of - l except the last element. *) -val incomplete_map : ('a -> 'a) -> 'a list -> 'a list +(** [map_butlast f l] applies f to all the elements of + l except the last element. *) +val map_butlast : ('a -> 'a) -> 'a list -> 'a list (** [last_element l] returns the last element of the list l.*) val last_element : 'a list -> 'a