Documentation
¶
Overview ¶
Package iterutil provides generic iterator utility functions for Go's iter.Seq type.
Index ¶
- func Any[V any](f func(V) bool, seq iter.Seq[V]) bool
- func AnyWith[V any](f func(V) bool) func(iter.Seq[V]) bool
- func Concat[V any](seqs ...iter.Seq[V]) iter.Seq[V]
- func Contains[V comparable](element V, seq iter.Seq[V]) bool
- func ContainsElement[V comparable](element V) func(iter.Seq[V]) bool
- func Delete[V any](f func(V) bool, seq iter.Seq[V]) iter.Seq[V]
- func DeleteWith[V any](f func(V) bool) func(iter.Seq[V]) iter.Seq[V]
- func Equal[V comparable](xit, yit iter.Seq[V]) bool
- func Filter[V any](f func(V) bool, seq iter.Seq[V]) iter.Seq[V]
- func FilterWith[V any](f func(V) bool) func(iter.Seq[V]) iter.Seq[V]
- func Find[V comparable](element V, seq iter.Seq[V]) bool
- func Map[In, Out any](f func(In) Out, seq iter.Seq[In]) iter.Seq[Out]
- func MapWith[In, Out any](f func(In) Out) func(iter.Seq[In]) iter.Seq[Out]
- func Reduce[Sum, V any](f func(Sum, V) Sum, sum Sum, seq iter.Seq[V]) Sum
- func ReduceWith[Sum, V any](f func(Sum, V) Sum, sum Sum) func(iter.Seq[V]) Sum
- func Zip[V1, V2 any](xit iter.Seq[V1], yit iter.Seq[V2]) iter.Seq[Zipped[V1, V2]]
- type Zipped
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Any ¶
Any returns true if at least one of the elements in seq matches the predicate f, false otherwise.
func AnyWith ¶
AnyWith returns a curried version of Any that takes a predicate function and returns a function that checks if any element matches.
func Contains ¶
func Contains[V comparable]( element V, seq iter.Seq[V], ) bool
Contains returns true if element is present in seq, false otherwise.
func ContainsElement ¶
func ContainsElement[V comparable](element V) func(iter.Seq[V]) bool
ContainsElement returns a curried version of Contains that takes an element and returns a function that checks if the element is present in a sequence.
func Delete ¶
Delete returns an iterator over seq that excludes the values v for which f(v) is true.
func DeleteWith ¶
DeleteWith returns a curried version of Delete that takes a predicate function and returns a function that removes matching elements from a sequence.
func Equal ¶
func Equal[V comparable](xit, yit iter.Seq[V]) bool
Equal reports whether the two sequences are equal.
func Filter ¶
Filter returns an iterator over seq that only includes the values v for which f(v) is true.
func FilterWith ¶
FilterWith returns a curried version of Filter that takes a predicate function and returns a function that filters a sequence.
func Find ¶
func Find[V comparable]( element V, seq iter.Seq[V], ) bool
Find is an alias for Contains.
func MapWith ¶
MapWith returns a curried version of Map that takes a transformation function and returns a function that applies it to a sequence.
func Reduce ¶
Reduce combines the values in seq using f. For each value v in seq, it updates sum = f(sum, v) and then returns the final sum. For example, if iterating over seq yields v1, v2, v3, Reduce returns f(f(f(sum, v1), v2), v3).
func ReduceWith ¶
ReduceWith returns a curried version of Reduce that takes a reducer function and initial value, returning a function that reduces a sequence.