src/Pure/library.scala
changeset 63867 fb46c031c841
parent 63789 af28929ff219
child 63926 70973a1b4ec0
--- a/src/Pure/library.scala	Wed Sep 14 12:51:40 2016 +0200
+++ b/src/Pure/library.scala	Wed Sep 14 12:56:57 2016 +0200
@@ -198,6 +198,11 @@
   def remove[A, B](x: B)(xs: List[A]): List[A] = if (member(xs)(x)) xs.filterNot(_ == x) else xs
   def update[A](x: A)(xs: List[A]): List[A] = x :: remove(x)(xs)
 
+  def merge[A](xs: List[A], ys: List[A]): List[A] =
+    if (xs.eq(ys)) xs
+    else if (xs.isEmpty) ys
+    else ys.foldRight(xs)(Library.insert(_)(_))
+
   def distinct[A](xs: List[A]): List[A] =
   {
     val result = new mutable.ListBuffer[A]