I defined natural
for Infinite sequence (Stream
) of Natural numbers with Java8 iterator
.
IntStream natural = IntStream.iterate(0, i -> i + 1);
natural
.limit(10)
.forEach(System.out::println);
Now, I want to define it with Java8 generator
.
static Stream generate(Supplier s)
What would be the simplest way? Thanks.