Proposal Details
iter.Seq
and iter.Seq2
open a wide range of possibilities to provide iterable views of data structures without involving memory copies.
While the Go standard library already provides some helper functions to create iter.Seq
(e.g. slices.Values
) or iter.Seq2
(e.g. maps.All
), it still lacks many usual functions to manipulate the sequences (e.g. filtering, modifying) or aggregating them (e.g. Reduce
, Max
, Min
).
I would like to offer the iters
package to fill this gap: https://github.com/mariomac/iters , the donation would contain whole package, or just a part, depending on the Go community needs and criteria.
iters
is a simple package relying only on the Go standard library that provides the following group of functionalities:
* Instantiation of sequences (instantiate.go
): creates sequences from slices, maps, varargs, numeric ranges, channels, and other sequences. It also allows generating infinite sequences from generator functions, or concatenating sequences.
* Transformations of sequences (transformers.go
): modify sequences (Map
, Peek
), filter them (Filter
, Distinct
), cut them (Limit
, Skip
)...
* Aggregations of sequences (terminals.go
): functional Reduce
operator, common aggregators like Count
, Max
, Min
, booleans (AllMatch
, AnyMatch
, NoneMatch
), etc...
Some examples in the project README: https://github.com/mariomac/iters/blob/main/README.md
For more information about the provided functions, please go to the API documentation https://pkg.go.dev/github.com/mariomac/iters
Key points of the iters
package:
* Convenience methods for common operations, based on a well-known specification like the Java Streams API, for faster familiarization with developers.
* Lazy evaluation allows working with infinite sequences without involving any copy of memory.
Comment From: apparentlymart
I think this earlier proposal overlaps this one: https://github.com/golang/go/issues/61898.
Comment From: mariomac
Thanks for the info @apparentlymart ! They totally overlap. Feel free to close te proposal if you think is not work repeating the same discussion again :)