reverted to v1.60 (PolyML 4.1.3 still has the wrong signature for Array.modifyi)
authorwebertj
Fri, 05 Jan 2007 15:33:05 +0100
changeset 22024 adf64b316f07
parent 22023 487b79b95a20
child 22025 7c5896919eb8
reverted to v1.60 (PolyML 4.1.3 still has the wrong signature for Array.modifyi)
src/HOL/Tools/refute.ML
--- a/src/HOL/Tools/refute.ML	Fri Jan 05 14:32:07 2007 +0100
+++ b/src/HOL/Tools/refute.ML	Fri Jan 05 15:33:05 2007 +0100
@@ -2229,7 +2229,21 @@
 												result
 											end
 									(* compute all entries in INTRS for the current datatype (given by 'index') *)
-									val _ = Array.modifyi (fn (i, _) => SOME (compute_array_entry index i)) ((Option.valOf o AList.lookup (op =) INTRS) index)
+									(* TODO: we can use Array.modify instead once PolyML conforms to the ML standard *)
+									(* (int * 'a -> 'a) -> 'a array -> unit *)
+									fun modifyi f arr =
+										let
+											val size = Array.length arr
+											fun modifyi_loop i =
+												if i < size then (
+													Array.update (arr, i, f (i, Array.sub (arr, i)));
+													modifyi_loop (i+1)
+												) else
+													()
+										in
+											modifyi_loop 0
+										end
+									val _ = modifyi (fn (i, _) => SOME (compute_array_entry index i)) ((Option.valOf o AList.lookup (op =) INTRS) index)
 									(* 'a Array.array -> 'a list *)
 									fun toList arr =
 										Array.foldr op:: [] arr