Re: Proposal: Stream.iterateWhile(T seed, Function> mapper)

2018-10-29 Thread Tomasz Linkowski
Two more things: 1) The example I provided might have been too simple to be convincing. Note that the proposed method is particularly useful when the Predicate (hasNext) has some common expensive part with the UnaryOperator (next). For example: boolean hasNext(Foo foo) { Bar bar = com

Proposal: Stream.iterateWhile(T seed, Function> mapper)

2018-10-26 Thread Tomasz Linkowski
Hi, Please, consider adding a new static method to the `Stream` interface (names TBD): static Stream iterateWhile( T seed, Function> mapper ); == OVERVIEW == + non-null equivalent of `Stream.iterate(seed, hasNext, next)` [1] + `mapper` like in `Optional.flatMap(map