summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlain Frisch <alain@frisch.fr>2010-05-25 11:22:14 +0000
committerAlain Frisch <alain@frisch.fr>2010-05-25 11:22:14 +0000
commite671780b01a86ad3f126017e814d126b8e4df1f9 (patch)
treef54dea63a9740e0a0741d740de5ffe4453ff8aed
parent9c07d1022f7924ef594a4c13c0f06df8a5f694dc (diff)
Fix PR#4012: Map.map and Map.mapi do not conform to specification.
git-svn-id: http://caml.inria.fr/svn/ocaml/trunk@10465 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
-rw-r--r--Changes1
-rw-r--r--stdlib/map.ml18
2 files changed, 15 insertions, 4 deletions
diff --git a/Changes b/Changes
index 4c309623e..c317af938 100644
--- a/Changes
+++ b/Changes
@@ -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