Created
November 17, 2011 07:04
-
-
Save gakuzzzz/1372563 to your computer and use it in GitHub Desktop.
無限Streamのgrouped
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> val s: Stream[Int] = Stream.continually {1} | |
s: Stream[Int] = Stream(1, ?) | |
scala> val i = s.grouped(3) | |
i: Iterator[scala.collection.immutable.Stream[Int]] = non-empty iterator | |
scala> i take 5 foreach println | |
Stream(1, ?) | |
Stream(1, ?) | |
Stream(1, ?) | |
Stream(1, ?) | |
Stream(1, ?) | |
scala> i take 5 foreach {x => x foreach println} | |
1 | |
1 | |
1 | |
1 | |
1 | |
1 | |
1 | |
1 | |
1 | |
1 | |
1 | |
1 | |
1 | |
1 | |
1 | |
scala> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment