src/Pure/library.ML
changeset 33081 fe29679cabc2
parent 33073 2f6ce3b9ec39
parent 33079 06a48bbeb22a
child 33206 fee21bb23d22
     1.1 --- a/src/Pure/library.ML	Fri Oct 23 06:53:50 2009 +0200
     1.2 +++ b/src/Pure/library.ML	Fri Oct 23 10:11:56 2009 +0200
     1.3 @@ -173,6 +173,7 @@
     1.4  
     1.5    (*lists as multisets*)
     1.6    val remove1: ('b * 'a -> bool) -> 'b -> 'a list -> 'a list
     1.7 +  val combine: ('a * 'a -> bool) -> 'a list -> 'a list -> 'a list
     1.8    val submultiset: ('a * 'b -> bool) -> 'a list * 'b list -> bool
     1.9  
    1.10    (*orders*)
    1.11 @@ -858,8 +859,10 @@
    1.12  
    1.13  (** lists as multisets **)
    1.14  
    1.15 -fun remove1 _ _ [] = raise Empty
    1.16 -  | remove1 eq y (x::xs) = if eq (y, x) then xs else x :: remove1 eq y xs;
    1.17 +fun remove1 eq x [] = []
    1.18 +  | remove1 eq x (y :: ys) = if eq (x, y) then ys else y :: remove1 eq x ys;
    1.19 +
    1.20 +fun combine eq xs ys = fold (remove1 eq) ys xs @ ys;
    1.21  
    1.22  fun submultiset _ ([], _)  = true
    1.23    | submultiset eq (x :: xs, ys) = member eq ys x andalso submultiset eq (xs, remove1 eq x ys);