giopt

package
v0.5.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 11, 2024 License: MIT Imports: 5 Imported by: 0

Documentation

Overview

Package giopt provides a set of generic iterator combinators over scalar values iter.Seq adapted for optval.Value.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FilterMap

func FilterMap[V, R any, F func(V) optval.Value[R]](values iter.Seq[V], f F) iter.Seq[R]

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

func FilterMapWith[V, R any, F func(V) optval.Value[R]](f F) func(values iter.Seq[V]) iter.Seq[R]

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 Find

func Find[V any, P constraints.Predicate[V]](values iter.Seq[V], predicate P) optval.Value[V]

Find returns the first value among the values matching the predicate.

func FindWith

func FindWith[V any, P constraints.Predicate[V]](predicate P) func(iter.Seq[V]) optval.Value[V]

FindWith returns a function that finds the first value among the values matching the predicate.

func Max

func Max[V constraints.Ordered](values iter.Seq[V]) optval.Value[V]

Max returns the maximum value of the given values or optval.None if values is empty.

func MaxBy

func MaxBy[V any, K constraints.Ordered, F ~func(V) K](values iter.Seq[V], key F) optval.Value[V]

MaxBy returns the maximum value of the given values or optval.None if values is empty. It uses provided key function for comparison.

func MaxByCompare

func MaxByCompare[V constraints.OrderedByCompare[V]](values iter.Seq[V]) optval.Value[V]

MaxByCompare returns the maximum value of the given values or optval.None if values is empty. It uses Compare method for comparison.

func MaxByCompareFunc

func MaxByCompareFunc[V any, F ~func(V, V) int](values iter.Seq[V], compare F) optval.Value[V]

MaxByCompareFunc returns the maximum value of the given values or optval.None if values is empty. It uses provided compare function for comparison.

func MaxByLess

func MaxByLess[V constraints.OrderedByLess[V]](values iter.Seq[V]) optval.Value[V]

MaxByLess returns the maximum value of the given values or optval.None if values is empty. It uses Less method for comparison.

func MaxByLessFunc

func MaxByLessFunc[V any, F ~func(V, V) bool](values iter.Seq[V], less F) optval.Value[V]

MaxByLessFunc returns the maximum value of the given values or optval.None if values is empty. It uses provided less function for comparison.

func Min

func Min[V constraints.Ordered](values iter.Seq[V]) optval.Value[V]

Min returns the minimum value of the given values or optval.None if values is empty.

func MinBy

func MinBy[V any, K constraints.Ordered, F ~func(V) K](values iter.Seq[V], key F) optval.Value[V]

MinBy returns the minimum value of the given values or optval.None value if values is empty. It uses provided key function for comparison.

func MinByCompare

func MinByCompare[V constraints.OrderedByCompare[V]](values iter.Seq[V]) optval.Value[V]

MinByCompare returns the minimum value of the given values or optval.None value if values is empty. It uses Compare method for comparison.

func MinByCompareFunc

func MinByCompareFunc[V any, F ~func(V, V) int](values iter.Seq[V], compare F) optval.Value[V]

MinByCompareFunc returns the minimum value of the given values or optval.None value if values is empty. It uses provided compare function for comparison.

func MinByLess

func MinByLess[V constraints.OrderedByLess[V]](values iter.Seq[V]) optval.Value[V]

MinByLess returns the minimum value of the given values or optval.None value if values is empty. It uses Less method for comparison.

func MinByLessFunc

func MinByLessFunc[V any, F ~func(V, V) bool](values iter.Seq[V], less F) optval.Value[V]

MinByLessFunc returns the minimum value of the given values or optval.None value if values is empty. It uses provided less function for comparison.

func Reduce

func Reduce[V any, F ~func(V, V) V](values iter.Seq[V], accumulate F) optval.Value[V]

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.

Reduce returns optval.None if the sequence is empty.

func ReduceWith

func ReduceWith[V any, F ~func(V, V) V](accumulate F) func(iter.Seq[V]) optval.Value[V]

ReduceWith returns a function that 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.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL