2

In functional-java, I expected the following to create an infinite stream:

Stream.forever(Enumerator.booleanEnumerator, false);

But it stops after one full enumeration. The javadoc kind of confirms this, stating that it may only stream until the enumeration is exhausted.

Returns a stream that is either infinite or bounded up to the maximum 
value of the given iterator starting at the given value and stepping at 
increments of 1.

So, how do I make an infinite stream?

leppie
  • 115,091
  • 17
  • 196
  • 297
Synesso
  • 37,610
  • 35
  • 136
  • 207

1 Answers1

1

You could look at Stream.cycle, it makes an infinite stream out of the input stream

Stream.cycle(Stream.forever(Enumerator.booleanEnumerator, false))
Shlomi
  • 4,708
  • 1
  • 23
  • 32