diff options
author | Paul Phillips <paulp@improving.org> | 2010-10-11 23:17:47 +0000 |
---|---|---|
committer | Paul Phillips <paulp@improving.org> | 2010-10-11 23:17:47 +0000 |
commit | e5c22d9e0a11f0c1a0d29520f7420d709fb174ec (patch) | |
tree | 819aed10c296f998cc082acb24b4835cd2eca224 /src/library/scala/Product3.scala | |
parent | 5c83be3b2bb200f53abd5e3c6667e78ce01ebe49 (diff) | |
download | scala-e5c22d9e0a11f0c1a0d29520f7420d709fb174ec.tar.gz scala-e5c22d9e0a11f0c1a0d29520f7420d709fb174ec.tar.bz2 scala-e5c22d9e0a11f0c1a0d29520f7420d709fb174ec.zip |
An overhaul of the collection-oriented methods ...
An overhaul of the collection-oriented methods in Tuple2/Tuple3 (which
still need to be taken all the way to Tuple5.)
* Zip semantics: zip and zipped now properly terminate when any
collection runs out of elements, even if others are infinite. In
addition, short circuiting methods (exists and forall) will terminate if
the condition is met, even in the presence of infinity.
Example:
scala> val ys = Stream from 1
ys: scala.collection.immutable.Stream[Int] = Stream(1, ?)
scala> (ys, ys).zipped forall ((x, y) => x+y < 100)
res0: Boolean = false
scala> (ys, ys).zipped exists ((x, y) => x+y > 100)
res1: Boolean = true
* There are implicits converting Zipped2/3 to Traversable to expose all
the methods which aren't defined in an arity-specific way in the tuple
classes. I have mixed feelings about putting these in Predef; but if
there is another way to make them visible by default I wasn't able to
find it.
Example putting said implicit to use:
scala> (ys, ys, ys).zipped find { case (x, y, z) => x+y+z > 1000 }
res0: Option[(Int, Int, Int)] = Some((334,334,334))
Already reviewed by moors, so no review.
Diffstat (limited to 'src/library/scala/Product3.scala')
-rw-r--r-- | src/library/scala/Product3.scala | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/src/library/scala/Product3.scala b/src/library/scala/Product3.scala index eb1ac7997c..c695b2c6c5 100644 --- a/src/library/scala/Product3.scala +++ b/src/library/scala/Product3.scala @@ -7,7 +7,7 @@ \* */ -// generated by genprod on Thu Sep 09 09:06:40 PDT 2010 +// generated by genprod on Thu Sep 16 10:52:35 PDT 2010 package scala |