(* Copyright 1989 by AT&T Bell Laboratories *)
structure SortedList =
struct
fun enter(new:int,l) =
let fun f [] = [new]
| f (l as h::t) = if newh then h::f t else l
in f l
end
fun merge(a,[]) = a
| merge([],a) = a
| merge(l as (i:int)::a, m as j::b) =
if j []
end
fun uniq l =
let fun split([],l,r) = (l,r)
| split(h::t,l,r) = split(t,r,h::l)
fun sort [] = []
| sort (l as [_]) = l
| sort (l as [x : int,y : int]) =
if x = y then [x] else if x < y then l else [y,x]
| sort l = let val (l,r) = split(l,[],[])
in merge(sort l, sort r) end
in sort l
end
fun remove(x as (xl:int)::xr, y as yl::yr) =
if xl>yl then yl::remove(x,yr) else remove(xr,if xl//