Created
April 9, 2016 16:53
-
-
Save kijuky/ec9451225eb175d426eb7d9ec3a31cdf to your computer and use it in GitHub Desktop.
Scala の filterNot が遅延評価されない (Scala 2.11.8)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ scala | |
Welcome to Scala 2.11.8 (Java HotSpot(TM) 64-Bit Server VM, Java 1.8.0_74). | |
Type in expressions for evaluation. Or try :help. | |
scala> val s = (1 to 10).toStream | |
s: scala.collection.immutable.Stream[Int] = Stream(1, ?) | |
scala> s.map(s => {println(" " + s); s}).filter(_ % 2 == 0).foreach(println) | |
1 | |
2 | |
2 | |
3 | |
4 | |
4 | |
5 | |
6 | |
6 | |
7 | |
8 | |
8 | |
9 | |
10 | |
10 | |
scala> s.map(s => {println(" " + s); s}).filterNot(_ % 2 == 0).foreach(println) | |
1 | |
2 | |
3 | |
4 | |
5 | |
6 | |
7 | |
8 | |
9 | |
10 | |
1 | |
3 | |
5 | |
7 | |
9 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment