Stream

unfold/2

unfold(acc, fun)

Emits a sequence of values for the given accumulator acc.

Successive values are generated by calling fun with the previous accumulator and it must return a tuple with the current value and next accumulator.

The enumeration finishes when fun returns nil.