TFL/utils.sml
changeset 3391 5e45dd3b64e9
parent 3330 ab7161e593c8
child 9867 bf8300fa4238
     1.1 --- a/TFL/utils.sml	Tue Jun 03 10:56:04 1997 +0200
     1.2 +++ b/TFL/utils.sml	Tue Jun 03 11:08:08 1997 +0200
     1.3 @@ -13,18 +13,6 @@
     1.4  exception ERR of {module:string,func:string, mesg:string};
     1.5  fun UTILS_ERR{func,mesg} = ERR{module = "Utils",func=func,mesg=mesg};
     1.6  
     1.7 -local 
     1.8 -fun info_string s {module,func,mesg} =
     1.9 -       (s^" at "^module^"."^func^":\n"^mesg^"\n")
    1.10 -in
    1.11 -val ERR_string = info_string "Exception raised"
    1.12 -val MESG_string = info_string "Message"
    1.13 -end;
    1.14 -
    1.15 -fun Raise (e as ERR sss) = (TextIO.output(TextIO.stdOut, ERR_string sss);  
    1.16 -                            raise e)
    1.17 -  | Raise e = raise e;
    1.18 -
    1.19  
    1.20  (* Simple combinators *)
    1.21  
    1.22 @@ -58,21 +46,12 @@
    1.23   in  it (L1,L2)
    1.24   end;
    1.25  
    1.26 -fun mapfilter f alist = itlist (fn i=>fn L=> (f i::L) handle _ => L) alist [];
    1.27 -
    1.28  fun pluck p  =
    1.29    let fun remv ([],_) = raise UTILS_ERR{func="pluck",mesg = "item not found"}
    1.30          | remv (h::t, A) = if p h then (h, rev A @ t) else remv (t,h::A)
    1.31    in fn L => remv(L,[])
    1.32    end;
    1.33  
    1.34 -fun front_back [] = raise UTILS_ERR{func="front_back",mesg="empty list"}
    1.35 -  | front_back [x] = ([],x)
    1.36 -  | front_back (h::t) = 
    1.37 -       let val (L,b) = front_back t
    1.38 -       in (h::L,b)
    1.39 -       end;
    1.40 -
    1.41  fun take f =
    1.42    let fun grab(0,L) = []
    1.43          | grab(n, x::rst) = f x::grab(n-1,rst)
    1.44 @@ -88,26 +67,6 @@
    1.45  fun holds P x = P x handle _ => false;
    1.46  
    1.47  
    1.48 -(* Set ops *)
    1.49 -nonfix mem;  (* Gag Barf Choke *)
    1.50 -fun mem eq_func i =
    1.51 -   let val eqi = eq_func i
    1.52 -       fun mm [] = false
    1.53 -         | mm (a::rst) = eqi a orelse mm rst
    1.54 -   in mm
    1.55 -   end;
    1.56 -
    1.57 -fun mk_set eq_func =
    1.58 -   let val mem = mem eq_func
    1.59 -       fun mk [] = []
    1.60 -         | mk (a::rst) = if (mem a rst) then mk rst else a::(mk rst)
    1.61 -   in mk
    1.62 -   end;
    1.63 -
    1.64 -(* All the elements in the first set that are not also in the second set. *)
    1.65 -fun set_diff eq_func S1 S2 = filter (fn x => not (mem eq_func x S2)) S1
    1.66 -
    1.67 -
    1.68  fun sort R = 
    1.69  let fun part (m, []) = ([],[])
    1.70        | part (m, h::rst) =