diff options
author | Philipp Haller <hallerp@gmail.com> | 2009-08-19 14:10:53 +0000 |
---|---|---|
committer | Philipp Haller <hallerp@gmail.com> | 2009-08-19 14:10:53 +0000 |
commit | c55580014c7d2aec878e9bd6387ba1f740083176 (patch) | |
tree | 87de9d8d400f63553dca77081fdd417d858f0ca0 /src | |
parent | d249bcf71f631ee9dc9e117a110137ca1d021ac3 (diff) | |
download | scala-c55580014c7d2aec878e9bd6387ba1f740083176.tar.gz scala-c55580014c7d2aec878e9bd6387ba1f740083176.tar.bz2 scala-c55580014c7d2aec878e9bd6387ba1f740083176.zip |
Second half of fix for #2177. Fixed #2255.
Diffstat (limited to 'src')
-rw-r--r-- | src/library/scala/collection/immutable/Stream.scala | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/src/library/scala/collection/immutable/Stream.scala b/src/library/scala/collection/immutable/Stream.scala index 00bc959fe4..badeb31bbc 100644 --- a/src/library/scala/collection/immutable/Stream.scala +++ b/src/library/scala/collection/immutable/Stream.scala @@ -237,6 +237,8 @@ self => super.mkString } + override def toString = super.mkString(stringPrefix + "(", ", ", ")") + /** Returns the <code>n</code> first elements of this stream, or else the whole * stream, if it has less than <code>n</code> elements. * @@ -341,6 +343,19 @@ self => result } + override def flatten[B](implicit toTraversable: A => Traversable[B]): Stream[B] = { + def flatten1(t: Traversable[B]): Stream[B] = + if (!t.isEmpty) + new Stream.Cons(t.head, flatten1(t.tail)) + else + tail.flatten + + if (isEmpty) + Stream.empty + else + flatten1(toTraversable(head)) + } + /** Defines the prefix of this object's <code>toString</code> representation as ``Stream''. */ override def stringPrefix = "Stream" |