diff options
-rw-r--r-- | Changes | 1 | ||||
-rw-r--r-- | stdlib/map.ml | 18 |
2 files changed, 15 insertions, 4 deletions
@@ -102,6 +102,7 @@ All tools: - PR#4857: add a -vnum option to display the version number and nothing else Bug Fixes: +- PR#4012: Map.map and Map.mapi do not conform to specification - PR#4478: better error messages for type definition mismatches - PR#4742: finalisation function raising an exception blocks other finalisations - PR#4775: compiler crash on crazy types (temporary fix) diff --git a/stdlib/map.ml b/stdlib/map.ml index b64fd7479..a159e7aef 100644 --- a/stdlib/map.ml +++ b/stdlib/map.ml @@ -150,12 +150,22 @@ module Make(Ord: OrderedType) = struct iter f l; f v d; iter f r let rec map f = function - Empty -> Empty - | Node(l, v, d, r, h) -> Node(map f l, v, f d, map f r, h) + Empty -> + Empty + | Node(l, v, d, r, h) -> + let l' = map f l in + let d' = f d in + let r' = map f r in + Node(l', v, d', r', h) let rec mapi f = function - Empty -> Empty - | Node(l, v, d, r, h) -> Node(mapi f l, v, f v d, mapi f r, h) + Empty -> + Empty + | Node(l, v, d, r, h) -> + let l' = mapi f l in + let d' = f v d in + let r' = mapi f r in + Node(l', v, d', r', h) let rec fold f m accu = match m with |