diff options
author | herbelin <herbelin@85f007b7-540e-0410-9357-904b9bb8a0f7> | 2002-01-18 15:28:44 +0000 |
---|---|---|
committer | herbelin <herbelin@85f007b7-540e-0410-9357-904b9bb8a0f7> | 2002-01-18 15:28:44 +0000 |
commit | 8aab9be00adcdc2b13150db4a963ee6123f447c2 (patch) | |
tree | 3f07d7c4b770939e968eb44941ef0bc00753d1ed /lib | |
parent | 96a51c9f3c1721b545c91b18e4d5af2b0864f165 (diff) |
List.map avec ordre des effets de bord garanti
git-svn-id: svn+ssh://scm.gforge.inria.fr/svn/coq/trunk@2410 85f007b7-540e-0410-9357-904b9bb8a0f7
Diffstat (limited to 'lib')
-rw-r--r-- | lib/util.ml | 7 | ||||
-rw-r--r-- | lib/util.mli | 1 |
2 files changed, 8 insertions, 0 deletions
diff --git a/lib/util.ml b/lib/util.ml index 5a02ffaef..0f5b3dbf5 100644 --- a/lib/util.ml +++ b/lib/util.ml @@ -121,6 +121,13 @@ let list_assign l n e = in assrec [] (l,n) +let list_map_left f = (* ensures the order in case of side-effects *) + let rec map_rec = function + | [] -> [] + | x::l -> let v = f x in v :: map_rec l + in + map_rec + let list_map_i f = let rec map_i_rec i = function | [] -> [] diff --git a/lib/util.mli b/lib/util.mli index 60504d9cf..2ed595ef1 100644 --- a/lib/util.mli +++ b/lib/util.mli @@ -65,6 +65,7 @@ val list_tabulate : (int -> 'a) -> int -> 'a list val list_assign : 'a list -> int -> 'a -> 'a list val list_distinct : 'a list -> bool val list_filter2 : ('a -> 'b -> bool) -> 'a list * 'b list -> 'a list * 'b list +val list_map_left : ('a -> 'b) -> 'a list -> 'b list val list_map_i : (int -> 'a -> 'b) -> int -> 'a list -> 'b list val list_map2_i : (int -> 'a -> 'b -> 'c) -> int -> 'a list -> 'b list -> 'c list |