1.1 --- a/test/Tools/isac/Knowledge/inssort.sml Thu Oct 28 11:05:24 2010 +0200
1.2 +++ b/test/Tools/isac/Knowledge/inssort.sml Fri Oct 29 15:54:16 2010 +0200
1.3 @@ -1,6 +1,28 @@
1.4 (* use"test-inssort.sml";
1.5 W.N.17.6.00
1.6 *)
1.7 +"--------------------------------------------------------";
1.8 +"--------------------------------------------------------";
1.9 +"table of contents --------------------------------------";
1.10 +"--------------------------------------------------------";
1.11 +"----------- inssort in SML -----------------------------";
1.12 +"--------------------------------------------------------";
1.13 +"--------------------------------------------------------";
1.14 +
1.15 +
1.16 +"----------- inssort in SML -----------------------------";
1.17 +"----------- inssort in SML -----------------------------";
1.18 +"----------- inssort in SML -----------------------------";
1.19 +fun foldr _ [] a = a
1.20 + | foldr f (x :: xs) a = foldr f xs (f a x);
1.21 +(*val foldr = fn : ('a -> 'b -> 'a) -> 'b list -> 'a -> 'a*)
1.22 +fun ins [] a = [a]
1.23 + | ins (x :: xs) a = if x < a then x :: (ins xs a) else a :: (x :: xs);
1.24 +(*val ins = fn : int list -> int -> int list*)
1.25 +fun sort xs = foldr ins xs [];
1.26 +(*val sort = fn : int list -> int list*)
1.27 +
1.28 +(*========== inhibit exn =======================================================
1.29
1.30 (* insertion sort, would need lists different from script-lists WN.11.00
1.31 WN.7.6.03: -"- started with someList :: 'a list => unl, fun dest_list *)
1.32 @@ -135,4 +157,5 @@
1.33
1.34 atomty (term_of (the scr));
1.35
1.36 -------- *)
1.37 \ No newline at end of file
1.38 +------- *)
1.39 +============ inhibit exn =====================================================*)