diff options
author | mihaylov <mihaylov@epfl.ch> | 2006-10-06 13:08:19 +0000 |
---|---|---|
committer | mihaylov <mihaylov@epfl.ch> | 2006-10-06 13:08:19 +0000 |
commit | 6aba5aeae5e78bb2c90140443bbe470cec7ab5d5 (patch) | |
tree | b8c772708b3fda4a18c7c44ba7b66fe9c0562072 | |
parent | c23c5ee74c0d020cebb3dbb9afd8284508bed1a1 (diff) | |
download | scala-6aba5aeae5e78bb2c90140443bbe470cec7ab5d5.tar.gz scala-6aba5aeae5e78bb2c90140443bbe470cec7ab5d5.tar.bz2 scala-6aba5aeae5e78bb2c90140443bbe470cec7ab5d5.zip |
In List.filter - prevent the second evaluation ...
In List.filter - prevent the second evaluation of the predicate on the elements on which it first fails (bug contrib #219)
-rw-r--r-- | src/library/scala/List.scala | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/src/library/scala/List.scala b/src/library/scala/List.scala index 57f28a91be..caf3757667 100644 --- a/src/library/scala/List.scala +++ b/src/library/scala/List.scala @@ -710,6 +710,9 @@ sealed abstract class List[+a] extends Seq[a] with CaseClass { b += these1.head these1 = these1.tail } + + these = these.tail // prevent the second evaluation of the predicate + // on the element on which it first failed while (!these.isEmpty) { if (p(these.head)) b += these.head these = these.tail |