How do I generate a stream of "new" data? Specifically, I want to be able to create data that includes functions that are not reversible. If I want to create a stream from an Array I do
Stream.of(arr)
col.stream()
A constant stream can be made with a lambda expression
Stream.generate(() -> "constant")
A stream based on the last input (any reversible function) may be achieved by
Stream.iterate(0, x -> x + 2)
But if I want to create a more general generator (say output of whether a number is divisive by three: 0,0,1,0,0,1,0,0,1...) without creating a new class.
The main issue is that I need to have some way of inputing the index into the lambda, because I want to have a pattern, and not to be dependent on the last output of the function.
Note:
someStream.limit(length)
may use to stop the length of the stream, so infinite stream generator is actually what I am looking for.