src/Pure/library.scala
changeset 68715 8197c2857267
parent 67885 839a624aabb9
child 69393 ed0824ef337e
--- a/src/Pure/library.scala	Fri Aug 03 15:04:24 2018 +0200
+++ b/src/Pure/library.scala	Fri Aug 03 15:29:11 2018 +0200
@@ -259,6 +259,15 @@
     result.toList
   }
 
+  def replicate[A](n: Int, a: A): List[A] =
+    if (n < 0) throw new IllegalArgumentException
+    else if (n == 0) Nil
+    else {
+      val res = new mutable.ListBuffer[A]
+      (1 to n).foreach(_ => res += a)
+      res.toList
+    }
+
 
   /* proper values */