Generators
Brian Goetz
brian.goetz at oracle.com
Thu Jan 3 11:49:00 PST 2013
I'm looking over our generators. Currently we have:
repeat(T)
repeat(n, T)
repeatedly(Supplier<T>)
repeatedly(n, Supplier<T>)
iterate(T, UnaryOperator<T>)
cycle(Iterable)
I'd like to pare this down a lot. Paul and I have been discussing
techniques for making limit() more efficient, at which point the first
four can collapse to
generate(Supplier<T>)
since you can simulate repeat(T) with generate(() -> T) and the limited
versions with generate().limit().
That leaves us with
iterate(T, UnaryOperator<T>)
cycle(Iterable)
and I'm thinking cycle doesn't pull its weight either. If we took that
out, we'd be down to the pleasantly small set of:
generate(Supplier<T>)
iterate(T, UnaryOperator<T>)
For integer generators, we have
range(from, to)
and I think we should add
ints() -> sugar for range(0, MAX_INT)
(Or should ints() be truly infinite, wrapping around?)
More information about the lambda-libs-spec-experts
mailing list