Thread
#stdlib
    r

    rrva

    4 years ago
    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

    rrva

    4 years ago
    does this work on streams as well?
    without collecting the stream first
    a

    Andreas Sinz

    4 years ago
    are we talking about Java-Streams or Kotlin Sequences?
    r

    rrva

    4 years ago
    Java-streams
    a

    Andreas Sinz

    4 years ago
    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