Commits

camlspotter committed 01d62da

more consing

  • Participants
  • Parent commits 30c8b77

Comments (0)

Files changed (1)

overload/ttmap.ml

 
   method ref f r = let self, v = f self !r in if !r == v then self, r else self, ref v
 
-  method list f xs = List.fold_right (fun x (self, xs) -> 
-    let self, x = f self x  in
-    self, x::xs) xs (self, [])
+  method list f xs = 
+    let self, ys = List.fold_right (fun x (self, xs) -> 
+      let self, x = f self x  in
+      self, x::xs) xs (self, [])
+    in
+    if List.for_all2 (==) xs ys then self, xs else self, ys 
 
   (* Oh it's really a map. not bind *)    
   method option f = function 
-    | Some v -> let self, v' = f self v in self, Some v'
+    | (Some v as o) -> let self, v' = f self v in if v == v' then self, o else self, Some v'
     | None -> self, None
 end