Skip to content

Commit 6484b53

Browse files
authored
Merge pull request #1358 from julienrf/lazy-collections
Update representation of un-evaluated collections as per scala/scala#8029
2 parents 7a60bfc + 557caf9 commit 6484b53

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

_overviews/collections-2.13/concrete-immutable-collection-classes.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ A [LazyList](http://www.scala-lang.org/api/{{ site.scala-213-version }}/scala/co
2525
Whereas lists are constructed with the `::` operator, lazy lists are constructed with the similar-looking `#::`. Here is a simple example of a lazy list containing the integers 1, 2, and 3:
2626

2727
scala> val lazyList = 1 #:: 2 #:: 3 #:: LazyList.empty
28-
lazyList: scala.collection.immutable.LazyList[Int] = LazyList(?)
28+
lazyList: scala.collection.immutable.LazyList[Int] = LazyList(<not computed>)
2929

3030
The head of this lazy list is 1, and the tail of it has 2 and 3. None of the elements are printed here, though, because the list
3131
hasn’t been computed yet! Lazy lists are specified to compute lazily, and the `toString` method of a lazy list is careful not to force any extra evaluation.
@@ -40,7 +40,7 @@ This function is deceptively simple. The first element of the sequence is clearl
4040
Here are the first few elements of the Fibonacci sequence starting with two ones:
4141

4242
scala> val fibs = fibFrom(1, 1).take(7)
43-
fibs: scala.collection.immutable.LazyList[Int] = LazyList(?)
43+
fibs: scala.collection.immutable.LazyList[Int] = LazyList(<not computed>)
4444
scala> fibs.toList
4545
res9: List[Int] = List(1, 1, 2, 3, 5, 8, 13)
4646

_overviews/collections-2.13/views.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -46,20 +46,20 @@ In the last statement, the expression `v map (_ + 1)` constructs a new vector wh
4646
Let's do this sequence of operations again, one by one:
4747

4848
scala> val vv = v.view
49-
vv: scala.collection.IndexedSeqView[Int] = View(?)
49+
vv: scala.collection.IndexedSeqView[Int] = IndexedSeqView(<not computed>)
5050

5151
The application `v.view` gives you an `IndexedSeqView[Int]`, i.e. a lazily evaluated `IndexedSeq[Int]`. Like with `LazyList`,
52-
the `toString` operation of views does not force the view elements, that’s why the content of `vv` is shown as `View(?)`.
52+
the `toString` operation of views does not force the view elements, that’s why the content of `vv` is shown as `IndexedSeqView(<not computed>)`.
5353

5454
Applying the first `map` to the view gives:
5555

5656
scala> vv map (_ + 1)
57-
res13: scala.collection.IndexedSeqView[Int] = View(?)
57+
res13: scala.collection.IndexedSeqView[Int] = IndexedSeqView(<not computed>)
5858

5959
The result of the `map` is another `IndexedSeqView[Int]` value. This is in essence a wrapper that *records* the fact that a `map` with function `(_ + 1)` needs to be applied on the vector `v`. It does not apply that map until the view is forced, however. Let's now apply the second `map` to the last result.
6060

6161
scala> res13 map (_ * 2)
62-
res14: scala.collection.IndexedSeqView[Int] = View(?)
62+
res14: scala.collection.IndexedSeqView[Int] = IndexedSeqView(<not computed>)
6363

6464
Finally, forcing the last result gives:
6565

0 commit comments

Comments
 (0)