If I have a stream of `[a, b, c, d]` what’s a simp...
# stdlib
r
If I have a stream of
[a, b, c, d]
what’s a simple and idiomatic way to transform this into a stream of pairs
[[a, b], [c, d]]
r
does this work on streams as well?
without collecting the stream first
a
are we talking about Java-Streams or Kotlin Sequences?
r
Java-streams
a
you have three choices: 1. replace
Stream
with
Sequence
and use
chunked
2.
stream.toSequence().chunked(2).toStream()
3. ask on stackoverflow or somewhere else how to do it in pure java