diff options
author | michelou <michelou@epfl.ch> | 2005-05-09 09:19:41 +0000 |
---|---|---|
committer | michelou <michelou@epfl.ch> | 2005-05-09 09:19:41 +0000 |
commit | 8cb91759c7b213999d93fc9e323ddced11322bc3 (patch) | |
tree | e7a5a77db6de6df26704ab9400c4b13c45042253 | |
parent | ea57a524befd666bc76879c7440aff94f32a04c5 (diff) | |
download | scala-8cb91759c7b213999d93fc9e323ddced11322bc3.tar.gz scala-8cb91759c7b213999d93fc9e323ddced11322bc3.tar.bz2 scala-8cb91759c7b213999d93fc9e323ddced11322bc3.zip |
- improved code of 'zipAll'.
-rw-r--r-- | sources/scala/List.scala | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/sources/scala/List.scala b/sources/scala/List.scala index af6283110a..2523862865 100644 --- a/sources/scala/List.scala +++ b/sources/scala/List.scala @@ -811,11 +811,12 @@ sealed trait List[+a] extends Seq[a] { def zipAll[c >: a, b](that: List[b], thisElem: c, thatElem: b): List[Pair[c,b]] = if (this.isEmpty && that.isEmpty) Nil - else { - val this1 = if (this.isEmpty) List.make(that.length, thisElem) else this; - val that1 = if (that.isEmpty) List.make(this.length, thatElem) else that; - Pair(this1.head, that1.head) :: this1.tail.zipAll(that1.tail, thisElem, thatElem) - } + else if (this.isEmpty) + List.make(that.length, thisElem) zip that + else if (that.isEmpty) + this zip List.make(this.length, thatElem) + else + Pair(this.head, that.head) :: this.tail.zipAll(that.tail, thisElem, thatElem); /** Computes the union of this list and the given list * <code>that</code>. |