diff options
Diffstat (limited to 'src/library')
-rw-r--r-- | src/library/scala/Stream.scala | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/src/library/scala/Stream.scala b/src/library/scala/Stream.scala index 034c9aa70f..fb8f5e92bd 100644 --- a/src/library/scala/Stream.scala +++ b/src/library/scala/Stream.scala @@ -154,6 +154,23 @@ object Stream { * @return the stream starting at value <code>start</code>. */ def from(start: Int): Stream[Int] = from(start, 1) + + /** + * Create an infinite stream containing the given element. + * + * @param elem the element composing the resulting stream + * @return the stream containing an inifinite number of elem + */ + def const[A](elem: A): Stream[A] = cons(elem, const(elem)) + + /** Create a stream containing several copies of an element. + * + * @param n the length of the resulting stream + * @param elem the element composing the resulting stream + * @return the stream composed of n elements all equal to elem + */ + def make[A](n: Int, elem: A): Stream[A] = + Stream.const(elem).take(n) } /** |