Documentation
¶
Overview ¶
Package seqe provides convering, filtering, and reducing operations for the [seq.SeqE] interface.
Index ¶
- func Accum[T any, S ~SeqE[T]](first T, seq S, merge func(T, T) T) (accumulator T, err error)
- func Accumm[T any, S ~SeqE[T]](first T, seq S, merge func(T, T) (T, error)) (accumulator T, err error)
- func Append[S ~SeqE[T], T any, TS ~[]T](seq S, out TS) (TS, error)
- func First[S ~SeqE[T], T any](seq S, predicate func(T) bool) (v T, ok bool, err error)
- func Firstt[S ~SeqE[T], T any](seq S, predicate func(T) (bool, error)) (v T, ok bool, err error)
- func ForEach[T any](seq SeqE[T], consumer func(T)) error
- func HasAny[S ~SeqE[T], T any](seq S, predicate func(T) bool) (bool, error)
- func Head[S ~SeqE[T], T any](seq S) (v T, ok bool, err error)
- func Reduce[S ~SeqE[T], T any](seq S, merge func(T, T) T) (T, error)
- func ReduceOK[S ~SeqE[T], T any](seq S, merge func(T, T) T) (result T, ok bool, err error)
- func Reducee[S ~SeqE[T], T any](seq S, merge func(T, T) (T, error)) (T, error)
- func ReduceeOK[S ~SeqE[T], T any](seq S, merge func(T, T) (T, error)) (result T, ok bool, err error)
- func Slice[S ~SeqE[T], T any](seq S) ([]T, error)
- func SliceCap[S ~SeqE[T], T any](seq S, capacity int) (out []T, err error)
- type SeqE
- func Conv[S ~SeqE[From], From, To any](seq S, converter func(From) (To, error)) SeqE[To]
- func Convert[S ~SeqE[From], From, To any](seq S, converter func(From) To) SeqE[To]
- func Filt[S ~SeqE[T], T any](seq S, filter func(T) (bool, error)) SeqE[T]
- func Filter[S ~SeqE[T], T any](seq S, filter func(T) bool) SeqE[T]
- func Skip[S ~SeqE[T], T any](n int, seq S) SeqE[T]
- func SkipWhile[S ~SeqE[T], T any](seq S, filter func(T) bool) SeqE[T]
- func Top[S ~SeqE[T], T any](n int, seq S) SeqE[T]
- func Union[S ~SeqE[T], T any](seq ...S) SeqE[T]
- func While[S ~SeqE[T], T any](seq S, filter func(T) bool) SeqE[T]
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Accum ¶
Accum accumulates a value by using the 'first' argument to initialize the accumulator and sequentially applying the 'merge' functon to the accumulator and each element of the 'seq' sequence.
func Accumm ¶
func Accumm[T any, S ~SeqE[T]](first T, seq S, merge func(T, T) (T, error)) (accumulator T, err error)
Accumm accumulates a value by using the 'first' argument to initialize the accumulator and sequentially applying the 'merge' functon to the accumulator and each element of the 'seq' sequence.
func ReduceOK ¶
ReduceOK reduces the elements of the seq into one using the 'merge' function. Returns ok==false if the seq returns ok=false at the first call (no more elements).
func ReduceeOK ¶
func ReduceeOK[S ~SeqE[T], T any](seq S, merge func(T, T) (T, error)) (result T, ok bool, err error)
ReduceeOK reduces the elements of the seq into one using the 'merge' function. Returns ok==false if the seq returns ok=false at the first call (no more elements).
Types ¶
type SeqE ¶
SeqE is a specific iterator form that allows to retrieve a value with an error as second parameter of the iterator. It is used as a result of applying functions like seq.Conv, which may throw an error during iteration. At each iteration step, it is necessary to check for the occurrence of an error.
for e, err := range seqence {
if err != nil {
break
}
...
}
func Conv ¶
Conv creates an errorable seq that applies the 'converter' function to the collection elements. The error should be checked at every iteration step, like:
var integers iter.Seq2[int, error]
...
for s, err := range seqe.Conv(integers, strconv.Itoa) {
if err != nil {
break
}
...
}
func Convert ¶
Convert creates an iterator that applies the 'converter' function to each iterable element.
func Filt ¶
Filt creates an erroreable iterator that iterates only those elements for which the 'filter' function returns true.
func Filter ¶
Filter creates an iterator that iterates only those elements for which the 'filter' function returns true.
func SkipWhile ¶
SkipWhile returns a sequence without first elements of the seq that dont'math the filter.