Documentation ¶
Overview ¶
Package gi provides a set of generic iterator combinators over scalar values iter.Seq.
Index ¶
- func And[T any, P constraints.Predicate[T]](predicates ...P) P
- func Any[T any, F constraints.Predicate[T]](predicate F) func(iter.Seq[T]) bool
- func Chunk[V any, I constraints.Integer](values iter.Seq[V], size I) iter.Seq[iter.Seq[V]]
- func ChunkToSlices[V any](values iter.Seq[V], size int) iter.Seq[[]V]
- func Cloned[V constraints.Cloneable[C], C any](values iter.Seq[V]) iter.Seq[C]
- func Concat[V any](values ...iter.Seq[V]) iter.Seq[V]
- func ConcatSlices[V any, VV ~[]V](values ...VV) iter.Seq[V]
- func Contains[V any, P constraints.Predicate[V]](values iter.Seq[V], predicate P) bool
- func Count[V any](values iter.Seq[V]) int
- func DivisibleBy[T constraints.Integer](divisor T) func(value T) bool
- func Each[T any, F constraints.Predicate[T]](predicate F) func(iter.Seq[T]) bool
- func Empty[V any]() iter.Seq[V]
- func Enumerate[V any](values iter.Seq[V]) iter.Seq2[int, V]
- func EnumerateFrom[V any, I constraints.Integer](begin I, values iter.Seq[V]) iter.Seq2[I, V]
- func Equal[T comparable](value T) func(T) bool
- func Even[T constraints.Integer](value T) bool
- func Every[V any, P constraints.Predicate[V]](values iter.Seq[V], predicate P) bool
- func Filter[V any, P constraints.Predicate[V]](values iter.Seq[V], predicate P) iter.Seq[V]
- func FilterMap[V, R any, F func(V) (R, bool)](values iter.Seq[V], f F) iter.Seq[R]
- func FilterMapWith[V, R any, F func(V) (R, bool)](f F) func(values iter.Seq[V]) iter.Seq[R]
- func FilterWith[V any, P constraints.Predicate[V]](predicate P) func(iter.Seq[V]) iter.Seq[V]
- func Find[V any, P constraints.Predicate[V]](values iter.Seq[V], predicate P) (V, bool)
- func FindWith[V any, P constraints.Predicate[V]](predicate P) func(iter.Seq[V]) (V, bool)
- func Flatten[V any](values iter.Seq[iter.Seq[V]]) iter.Seq[V]
- func FlattenBy[VV any, V any, F ~func(VV) iter.Seq[V]](values iter.Seq[VV], f F) iter.Seq[V]
- func FlattenSlices[V any, VV ~[]V](values iter.Seq[VV]) iter.Seq[V]
- func Fold[V, R any, F ~func(R, V) R](values iter.Seq[V], initial R, accumulate F) R
- func FoldWith[V, R any, F ~func(R, V) R](initial R, accumulate F) func(iter.Seq[V]) R
- func Greater[T constraints.Ordered](value T) func(T) bool
- func GreaterOrEqual[T constraints.Ordered](value T) func(T) bool
- func In[T comparable, TT ~[]T](values TT) func(T) bool
- func IsNone[V any](_ V, some bool) bool
- func IsNotZero[T comparable](value T) bool
- func IsSome[V any](_ V, some bool) bool
- func IsZero[T comparable](value T) bool
- func Less[T constraints.Ordered](value T) func(T) bool
- func LessOrEqual[T constraints.Ordered](value T) func(T) bool
- func Limit[V any, I constraints.Integer](n I, values iter.Seq[V]) iter.Seq[V]
- func Loop[V any](seq iter.Seq[V]) iter.Seq[V]
- func LoopSingle[V any](value V) iter.Seq[V]
- func Map[V, R any, F ~func(V) R](values iter.Seq[V], transform F) iter.Seq[R]
- func MapWith[V, R any, F ~func(V) R](transform F) func(iter.Seq[V]) iter.Seq[R]
- func Max[V constraints.Ordered](values iter.Seq[V]) (V, bool)
- func MaxBy[V any, K constraints.Ordered, F ~func(V) K](values iter.Seq[V], key F) (V, bool)
- func MaxByCompare[V constraints.OrderedByCompare[V]](values iter.Seq[V]) (V, bool)
- func MaxByCompareFunc[V any, F ~func(V, V) int](values iter.Seq[V], compare F) (V, bool)
- func MaxByLess[V constraints.OrderedByLess[V]](values iter.Seq[V]) (V, bool)
- func MaxByLessFunc[V any, F ~func(V, V) bool](values iter.Seq[V], less F) (V, bool)
- func Min[V constraints.Ordered](values iter.Seq[V]) (V, bool)
- func MinBy[V any, K constraints.Ordered, F ~func(V) K](values iter.Seq[V], key F) (V, bool)
- func MinByCompare[V constraints.OrderedByCompare[V]](values iter.Seq[V]) (V, bool)
- func MinByCompareFunc[V any, F ~func(V, V) int](values iter.Seq[V], compare F) (V, bool)
- func MinByLess[V constraints.OrderedByLess[V]](values iter.Seq[V]) (V, bool)
- func MinByLessFunc[V any, F ~func(V, V) bool](values iter.Seq[V], less F) (V, bool)
- func Not[T any, P constraints.Predicate[T]](predicate P) P
- func NotEqual[T comparable](value T) func(T) bool
- func Odd[T constraints.Integer](value T) bool
- func OneOf[T comparable](values ...T) func(T) bool
- func Or[T any, P constraints.Predicate[T]](predicates ...P) P
- func Product[V constraints.Number](values iter.Seq[V]) V
- func Reduce[V any, F ~func(V, V) V](values iter.Seq[V], accumulate F) (V, bool)
- func ReduceWith[V any, F ~func(V, V) V](accumulate F) func(iter.Seq[V]) (V, bool)
- func Repeat[V any, I constraints.Integer](seq iter.Seq[V], n I) iter.Seq[V]
- func RepeatSingle[V any, I constraints.Integer](value V, n I) iter.Seq[V]
- func Single[V any](value V) iter.Seq[V]
- func Sum[V constraints.Number](values iter.Seq[V]) V
- func Values[V any](values ...V) iter.Seq[V]
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func And ¶
func And[T any, P constraints.Predicate[T]](predicates ...P) P
And returns a predicate that returns true only in case all of the given predicates return true. And returns true if there are no given predicates.
func Any ¶ added in v0.4.0
Any returns a predicate that takes a sequence of values and returns true in case any of the values in the sequence satisfy the given predicate.
func ChunkToSlices ¶
ChunkToSlices returns a new iterator that yields slices of size elements from the given values.
func ConcatSlices ¶
ConcatSlices returns an iterator that over concatenation of the given slices.
func DivisibleBy ¶
func DivisibleBy[T constraints.Integer](divisor T) func(value T) bool
DivisibleBy returns a predicate that returns true if its argument can be divided by the given divisor without a remainder.
func Each ¶ added in v0.4.0
Each returns a predicate that takes a sequence of values and returns true in case all of the values in the sequence satisfy the given predicate.
func Enumerate ¶ added in v0.4.0
Enumerate returns an iterator over the given values, yielding pairs of the index and the value.
func EnumerateFrom ¶ added in v0.4.0
EnumerateFrom returns an iterator over the given values, yielding pairs of the index and the value. The index starts from the given begin value.
func Equal ¶
func Equal[T comparable](value T) func(T) bool
Equal returns a predicate that returns true in case its argument is equal to the value.
func Even ¶
func Even[T constraints.Integer](value T) bool
Even returns true if the value can be divided by 2 without a remainder.
func FilterMap ¶ added in v0.4.0
FilterMap returns an iterator that yields values by applying the provided filter-map function to values. The filter-map function returns an optional value. If the optional value is empty, the value is skipped.
func FilterMapWith ¶ added in v0.4.0
FilterMapWith returns a function that can be used to filter-map sequences of values. It uses the provided filter-map function to transform and filter values. If the optional value is empty, the value is skipped.
func FilterWith ¶ added in v0.4.0
FilterWith returns a function that filters an iterator sequence over values using a predicate.
func FindWith ¶ added in v0.4.0
FindWith returns a function that finds the first value among the values matching the predicate.
func FlattenBy ¶
FlattenBy returns an iterator that flattens the values of the given iterator using the provided function.
func FlattenSlices ¶
FlattenSlices returns an iterator that flattens the slices of the given iterator.
func Fold ¶
Fold reduces the slice of values to a value which is the accumulated result of running accumulate function on each element where each successive invocation is supplied the return value of the previous one.
func FoldWith ¶ added in v0.4.0
FoldWith returns a function that can be used to fold sequences of values.
func Greater ¶
func Greater[T constraints.Ordered](value T) func(T) bool
Greater returns a predicate that returns true in case its argument is greater than the value.
func GreaterOrEqual ¶
func GreaterOrEqual[T constraints.Ordered](value T) func(T) bool
GreaterOrEqual returns a predicate that returns true in case its argument is greater or equal than the value.
func In ¶
func In[T comparable, TT ~[]T](values TT) func(T) bool
In returns a predicate that returns true in case its argument is contained in the given slice of values.
func IsNone ¶ added in v0.4.0
IsNone returns true if the right value of the given pair of values is false. Otherwise, it returns false. This function is useful for checking if a value is absent in an optional value.
func IsNotZero ¶ added in v0.2.0
func IsNotZero[T comparable](value T) bool
IsNotZero returns true if the value is not equal to the zero value of its type.
func IsSome ¶ added in v0.4.0
IsSome returns true if the right value of the given pair of values is true. Otherwise, it returns false. This function is useful for checking if a value is present in an optional value.
func IsZero ¶ added in v0.2.0
func IsZero[T comparable](value T) bool
IsZero returns true if the value is equal to the zero value of its type.
func Less ¶
func Less[T constraints.Ordered](value T) func(T) bool
Less returns a predicate that returns true in case its argument is less than the value.
func LessOrEqual ¶
func LessOrEqual[T constraints.Ordered](value T) func(T) bool
LessOrEqual returns a predicate that returns true in case its argument is less or equal than the value.
func Loop ¶ added in v0.4.0
Loop returns an iterator that yields the same sequence of values repeatedly.
func LoopSingle ¶ added in v0.4.0
LoopSingle returns an iterator that yields the same value repeatedly.
func MapWith ¶ added in v0.4.0
MapWith returns a function that transforms an iterator sequence over values to an iterator sequence over transformed values.
func Max ¶
func Max[V constraints.Ordered](values iter.Seq[V]) (V, bool)
Max returns the maximum value of the given values and true if values is not empty. Otherwise, it returns the zero value of the value type and false.
func MaxBy ¶
MaxBy returns the maximum value of the given values and true if values is not empty. Otherwise, it returns the zero value of the value type and false. It uses the provided key function for comparison.
func MaxByCompare ¶
func MaxByCompare[V constraints.OrderedByCompare[V]](values iter.Seq[V]) (V, bool)
MaxByCompare returns the maximum value of the given values and true if values is not empty. Otherwise, it returns the zero value of the value type and false. It uses the Compare method for comparison.
func MaxByCompareFunc ¶
MaxByCompareFunc returns the maximum value of the given values and true if values is not empty. Otherwise, it returns the zero value of the value type and false. It uses the provided compare function for comparison.
func MaxByLess ¶
func MaxByLess[V constraints.OrderedByLess[V]](values iter.Seq[V]) (V, bool)
MaxByLess returns the maximum value of the given values and true if values is not empty. Otherwise, it returns the zero value of the value type and false. It uses the Less method for comparison.
func MaxByLessFunc ¶
MaxByLessFunc returns the maximum value of the given values and true if values is not empty. Otherwise, it returns the zero value of the value type and false. It uses the provided less function for comparison.
func Min ¶
func Min[V constraints.Ordered](values iter.Seq[V]) (V, bool)
Min returns the minimum value of the given values and true if values is not empty. Otherwise, it returns the zero value of the value type and false.
func MinBy ¶
MinBy returns the minimum value of the given values and true if values is not empty. Otherwise, it returns the zero value of the value type and false. It uses the provided key function for comparison.
func MinByCompare ¶
func MinByCompare[V constraints.OrderedByCompare[V]](values iter.Seq[V]) (V, bool)
MinByCompare returns the minimum value of the given values and true if values is not empty. Otherwise, it returns the zero value of the value type and false. It uses the Compare method for comparison.
func MinByCompareFunc ¶
MinByCompareFunc returns the minimum value of the given values and true if values is not empty. Otherwise, it returns the zero value of the value type and false. It uses the provided compare function for comparison.
func MinByLess ¶
func MinByLess[V constraints.OrderedByLess[V]](values iter.Seq[V]) (V, bool)
MinByLess returns the minimum value of the given values and true if values is not empty. Otherwise, it returns the zero value of the value type and false. It uses the Less method for comparison.
func MinByLessFunc ¶
MinByLessFunc returns the minimum value of the given values and true if values is not empty. Otherwise, it returns the zero value of the value type and false. It uses the provided less function for comparison.
func Not ¶
func Not[T any, P constraints.Predicate[T]](predicate P) P
Not returns a predicate that returns negated value of the given predicate.
func NotEqual ¶
func NotEqual[T comparable](value T) func(T) bool
NotEqual returns a predicate that returns true in case its argument is not equal to the value.
func Odd ¶
func Odd[T constraints.Integer](value T) bool
Odd returns true if the value can not be divided by 2 without a remainder.
func OneOf ¶
func OneOf[T comparable](values ...T) func(T) bool
OneOf returns a predicate that returns true in case its argument is equal to one of the given values.
func Or ¶
func Or[T any, P constraints.Predicate[T]](predicates ...P) P
Or returns a predicate that returns true only in case any of the given predicates return true. Or returns false if there are no given predicates.
func Product ¶
func Product[V constraints.Number](values iter.Seq[V]) V
Product returns the product of the given values.
func Reduce ¶
Reduce reduces the values to a value which is the accumulated result of running accumulate function on each element where each successive invocation is supplied the return value of the previous one.
It returns zero value and false if the sequence is empty.
func ReduceWith ¶ added in v0.4.0
ReduceWith returns a function that can be used to reduce sequences of values in a single value.
func Repeat ¶ added in v0.4.0
Repeat returns an iterator that yields the same sequence of values repeatedly n times.
func RepeatSingle ¶ added in v0.4.0
func RepeatSingle[V any, I constraints.Integer](value V, n I) iter.Seq[V]
RepeatSingle returns an iterator that yields the same single value repeatedly n times.
Types ¶
This section is empty.
Source Files ¶
Directories ¶
Path | Synopsis |
---|---|
Package constraints provides constraints for generic iterator helpers.
|
Package constraints provides constraints for generic iterator helpers. |
Package gi2 provides a set of generic iterator combinators over pairs of values iter.Seq2.
|
Package gi2 provides a set of generic iterator combinators over pairs of values iter.Seq2. |
Package gi2op provides a set of binary operators on pairs of values for generic iterator combinators.
|
Package gi2op provides a set of binary operators on pairs of values for generic iterator combinators. |
Package gi2opt provides a set of generic iterator combinators over pairs of values iter.Seq adapted for optpair.Pair.
|
Package gi2opt provides a set of generic iterator combinators over pairs of values iter.Seq adapted for optpair.Pair. |
Package giop provides a set of binary operators on scalar values for generic iterator combinators.
|
Package giop provides a set of binary operators on scalar values for generic iterator combinators. |
Package giopt provides a set of generic iterator combinators over scalar values iter.Seq adapted for optval.Value.
|
Package giopt provides a set of generic iterator combinators over scalar values iter.Seq adapted for optval.Value. |
internal
|
|
testing/helpers
Package helpers provides helper functions for testing.
|
Package helpers provides helper functions for testing. |