You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
interleave potentially many elements (provide Function<T, List<T>>)
receive all elements since previous interleave (i.e. if the last function call didn't return an element to interleave, provide both former stream elements as input; UnaryOperator<List<T>>)
Each of these use cases includes the previous ones, so allowing just the last one would catch three birds with one gatherer (I couldn't help myself) but with an API that is more annoying that needed for the simpler (and probably more common) use cases.
The text was updated successfully, but these errors were encountered:
Interesting idea! I implemented something like this (mapWithOriginal) and parked it in a feature branch I haven't pushed, but the concept is really similar. I like your implementation, and I appreciate the detailed analysis (and the joke!). Let me look at it, this sounds like a fun idea. What kind of problem were you solving where you needed this, if I might ask?
What kind of problem were you solving where you needed this, if I might ask?
Funny you should ask - I can't remember details and I can't find the calls site or implementation, either. 😅 It may have fallen victim to a refactoring and consequent removal of unused code. But if I remember correctly, it wasn't something simple like in the example above but a "complex" object being constructed.
I had an interleave use case where the interleaved elements were computed from the previous element. The use looked as follows:
There are other use cases in this realm, though:
Function<T, Optional<T>>
)Function<T, List<T>>
)UnaryOperator<List<T>>
)Each of these use cases includes the previous ones, so allowing just the last one would catch three birds with one gatherer (I couldn't help myself) but with an API that is more annoying that needed for the simpler (and probably more common) use cases.
The text was updated successfully, but these errors were encountered: