Stream generators
Brian Goetz
brian.goetz at oracle.com
Fri Nov 30 09:21:37 PST 2012
We've got a few generators for infinite streams already implemented.
For object streams:
// produces seed, f(seed), f(f(seed)), ...
<T> iterate(T seed, UnaryOperator<T> f)
// infinite constant sequence
<T> repeat(T t)
// finite constant sequence
<T> repeat(int n, T t)
// infinite sequence driven by a supplier function
<T> repeatedly(Supplier<T> f)
// finite sequence driven by a supplier function
<T> repeatedly(int n, Supplier<T> f)
// infinitely cycle through an Iterable
<T> cycle(Iterable<T> iterable)
For integer streams, the above, plus
range(int from, int to)
range(int from, int to, int step)
Ignoring naming for the time being:
- Do these carry their weight?
- Are we missing any?
- What related functionality are we missing that might undermine the
utility of these (e.g., zip)?
More information about the lambda-libs-spec-observers
mailing list