Stream generators (original) (raw)

Brian Goetz brian.goetz at oracle.com
Fri Nov 30 12:11:14 PST 2012


I don't think that infinite streams pull their weight,

Well, they don't weigh that much, either -- they don't introduce new concepts, they are just other ways to get a stream. I think an integer range generator would be a reasonable minimum.

Many of the examples below can be synthesized from int ranges plus existing stream ops:

intRange(...).map(e -> k)

The "repeatedly" sequences also can be easily synthesized:

intRange(...).map(e -> supplier.get())

I've had lab for 2 or 3 years where students play with with infinite iterators and lists, and it was always evaluated by student (our students grade labs, TA, profs etc.) as too difficult so the lab was eventually replaced.

Rémi On 11/30/2012 06:21 PM, Brian Goetz wrote: We've got a few generators for infinite streams already implemented. For object streams:

// produces seed, f(seed), f(f(seed)), ... iterate(T seed, UnaryOperator f) // infinite constant sequence repeat(T t) // finite constant sequence repeat(int n, T t) // infinite sequence driven by a supplier function repeatedly(Supplier f) // finite sequence driven by a supplier function repeatedly(int n, Supplier f) // infinitely cycle through an Iterable cycle(Iterable 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