Documentation
¶
Overview ¶
Package ranges provides combinators for iter.Seq iterators: Filter, Map, Limit, Join, Unique, Empty, and Values, plus Slice to collect one.
Everything here is lazy. Each combinator returns a new iter.Seq that pulls from its source only as the consumer ranges over it, so chaining them composes a single pass rather than building intermediate slices, and stopping early stops the whole chain.
This is the modern counterpart to the iterator package, which adapts the older cursor-style interface. New code should start here.
Index ¶
- func Empty[T any]() iter.Seq[T]
- func Filter[T any](iterator iter.Seq[T], predicate func(T) bool) iter.Seq[T]
- func FilterPointer[T any](iterator iter.Seq[T], predicate func(*T) bool) iter.Seq[T]
- func Join[T any](iterators ...iter.Seq[T]) iter.Seq[T]
- func Limit[T any](max int, iterator iter.Seq[T]) iter.Seq[T]
- func Map[IN any, OUT any](iterator iter.Seq[IN], transform func(IN) OUT) iter.Seq[OUT]
- func Slice[T any](rangeFunc iter.Seq[T]) []T
- func Unique[T comparable](fn iter.Seq[T]) iter.Seq[T]
- func Values[T any](values ...T) iter.Seq[T]
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Filter ¶ added in v0.25.28
Filter returns a new iterator that yields only the items from the input iterator for which the predicate function returns true.
func FilterPointer ¶ added in v0.25.34
FilterPointer returns a new iterator that yields only the items from the input iterator for which the predicate function returns true.
func Join ¶ added in v0.25.28
Join combines multiple iterators into a single iterator that yields all items from each input iterator in sequence.
func Map ¶ added in v0.25.28
Map transforms a rangeFunc of type T into a rangeFunc of type U using the provided transform function.
Types ¶
This section is empty.