Skip to content

Instantly share code, notes, and snippets.

@gakuzzzz
Created November 17, 2011 07:04
Show Gist options
  • Save gakuzzzz/1372563 to your computer and use it in GitHub Desktop.
Save gakuzzzz/1372563 to your computer and use it in GitHub Desktop.
無限Streamのgrouped
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