diff options
| author | coqbot-app[bot] | 2020-10-27 20:33:46 +0000 |
|---|---|---|
| committer | GitHub | 2020-10-27 20:33:46 +0000 |
| commit | 96354508a50f12a2af49bd95073c6a24cea69713 (patch) | |
| tree | 5c79f26f6cb771a78ff935396bb3f67690239ab3 | |
| parent | 5f5cddae48c08872107f30938dcc2f3c8d91f33a (diff) | |
| parent | dcb325fd6ef432cd3717264c1547b94c7da2f396 (diff) | |
Merge PR #13226: Restore the List.Smart.map original implementation.
Reviewed-by: gares
| -rw-r--r-- | clib/cList.ml | 20 |
1 files changed, 6 insertions, 14 deletions
diff --git a/clib/cList.ml b/clib/cList.ml index 057200f83e..6b13fac48c 100644 --- a/clib/cList.ml +++ b/clib/cList.ml @@ -1019,20 +1019,12 @@ let rec factorize_left cmp = function module Smart = struct - let rec map_loop f p = function - | [] -> () - | x :: l' as l -> - let x' = f x in - map_loop f p l'; - if x' == x && !p == l' then p := l else p := x' :: !p - - let map f = function - | [] -> [] - | x :: l' as l -> - let p = ref [] in - let x' = f x in - map_loop f p l'; - if x' == x && !p == l' then l else x' :: !p + let rec map f l = match l with + | [] -> l + | h :: tl -> + let h' = f h in + let tl' = map f tl in + if h' == h && tl' == tl then l else h' :: tl' end |
