added separate;
authorwenzelm
Thu, 06 May 2010 23:32:29 +0200
changeset 36688 321d392ab12e
parent 36687 58020b59baf7
child 36689 379f5b1e7f91
added separate;
src/Pure/library.scala
--- a/src/Pure/library.scala	Thu May 06 23:07:21 2010 +0200
+++ b/src/Pure/library.scala	Thu May 06 23:32:29 2010 +0200
@@ -13,6 +13,15 @@
 
 object Library
 {
+  /* separate */
+
+  def separate[A](s: A, list: List[A]): List[A] =
+    list match {
+      case x :: xs if !xs.isEmpty => x :: s :: separate(s, xs)
+      case _ => list
+    }
+
+
   /* reverse CharSequence */
 
   class Reverse(text: CharSequence, start: Int, end: Int) extends CharSequence