pasted old insertion sort (does not work with new sort function!)
authorwenzelm
Fri, 19 Dec 1997 10:33:59 +0100
changeset 4453 bcb28bb925c1
parent 4452 b2ee34200dab
child 4454 2e089fae6ed7
pasted old insertion sort (does not work with new sort function!)
src/Provers/splitter.ML
--- a/src/Provers/splitter.ML	Fri Dec 19 10:33:24 1997 +0100
+++ b/src/Provers/splitter.ML	Fri Dec 19 10:33:59 1997 +0100
@@ -179,6 +179,18 @@
    call split_posns with appropriate parameters
 *************************************************************)
 
+(* FIXME *)
+(*insertion sort; stable (does not reorder equal elements)
+  'less' is less-than test on type 'a*)
+fun sort (less: 'a*'a -> bool) =
+  let fun insert (x, []) = [x]
+        | insert (x, y::ys) =
+              if less(y, x) then y :: insert (x, ys) else x::y::ys;
+      fun sort1 [] = []
+        | sort1 (x::xs) = insert (x, sort1 xs)
+  in  sort1  end;
+
+
 fun select cmap state i =
   let val goali = nth_subgoal i state
       val Ts = rev(map #2 (Logic.strip_params goali))