Documentation ¶
Index ¶
- func Accumulate[Elem constraints.Integer | constraints.Float](seq iter.Seq[Elem]) iter.Seq[Elem]
- func All[V any](seq iter.Seq[V], f func(V) bool) bool
- func Any[V any](seq iter.Seq[V], f func(V) bool) bool
- func Concat[V any](seqs ...iter.Seq[V]) iter.Seq[V]
- func Contains[T comparable](seq iter.Seq[T], v T) bool
- func ContainsBy[T any](seq iter.Seq[T], f func(T) bool) bool
- func Count[T any](seq iter.Seq[T]) (cnt int)
- func Count2[K any, V any](seq iter.Seq2[K, V]) (cnt int)
- func Cycle[Elem any](seq iter.Seq[Elem]) iter.Seq[Elem]
- func Enumerate[V any](seq iter.Seq[V]) iter.Seq2[int, V]
- func EnumerateByStep[V any](seq iter.Seq[V], start, step int) iter.Seq2[int, V]
- func Equal[V comparable](x, y iter.Seq[V]) bool
- func Filter[V any](f func(V) bool, seq iter.Seq[V]) iter.Seq[V]
- func Find[T any](seq iter.Seq[T], f func(T) bool) (T, int, bool)
- func FindOrElse[T any](seq iter.Seq[T], fallback T, f func(T) bool) T
- func Firsts[K any, V any](seq iter.Seq2[K, V]) iter.Seq[K]
- func ForEach[V any](seq iter.Seq[V], f func(V))
- func FromChannel[T any](ch <-chan T) iter.Seq[T]
- func IndexOf[T comparable](seq iter.Seq[T], v T) int
- func Last[T any](seq iter.Seq[T]) (T, bool)
- func Limit[V any](seq iter.Seq[V], n int) iter.Seq[V]
- func Limit2[K any, V any](seq iter.Seq2[K, V], n int) iter.Seq2[K, V]
- func Map[In, Out any](f func(In) Out, seq iter.Seq[In]) iter.Seq[Out]
- func Max[T constraints.Ordered](seq iter.Seq[T]) (T, bool)
- func MaxBy[T any](seq iter.Seq[T], f func(T, T) bool) (T, bool)
- func Min[T constraints.Ordered](seq iter.Seq[T]) (T, bool)
- func Next[T any](seq iter.Seq[T]) (T, bool)
- func Nth[T any](seq iter.Seq[T], n int) (T, bool)
- func Range(end int) iter.Seq[int]
- func RangeByStep[T constraints.Integer | constraints.Float](start, end, step T) iter.Seq[T]
- func RangeFrom[T constraints.Integer | constraints.Float](start, step T) iter.Seq[T]
- func Repeat[Elem any](e Elem) iter.Seq[Elem]
- func RepeatN[Elem any](e Elem, n int) iter.Seq[Elem]
- func Seconds[K any, V any](seq iter.Seq2[K, V]) iter.Seq[V]
- func Skip[V any](seq iter.Seq[V], n int) iter.Seq[V]
- func ToChannel[T any](seq iter.Seq[T]) <-chan T
- func Zip[V1, V2 any](x iter.Seq[V1], y iter.Seq[V2]) iter.Seq[Zipped[V1, V2]]
- type Pair
- type Zipped
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Accumulate ¶
func Accumulate[Elem constraints.Integer | constraints.Float](seq iter.Seq[Elem]) iter.Seq[Elem]
Accumulate returns an iterator that returns accumulated sums.
func Contains ¶
func Contains[T comparable](seq iter.Seq[T], v T) bool
Contains returns true if seq contains v.
func ContainsBy ¶
ContainsBy returns true if seq contains an element that satisfies f.
func Cycle ¶
Cycle returns an iterator returning elements from the iterable and saving a copy of each. When the iterable is exhausted, return elements from the saved copy. Repeats indefinitely.
func Enumerate ¶
Enumerate returns an iterator that returns (0, seq[0]), (1, seq[1]), (2, seq[2]), ...
func EnumerateByStep ¶
EnumerateByStep returns an iterator that returns (start, seq[0]), (start+step, seq[1]), (start+2*step, seq[2]), ...
func Equal ¶
func Equal[V comparable](x, y 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 Find ¶
Find searches for an element satisfying f in seq. If found, it returns the element and its index and true. Otherwise, it returns the zero value, -1, and false.
func FindOrElse ¶
FindOrElse searches for an element satisfying f in seq. If found, it returns the element. Otherwise, it returns fallback.
func FromChannel ¶
FromChannel returns a sequence from a channel.
func IndexOf ¶
func IndexOf[T comparable](seq iter.Seq[T], v T) int
IndexOf returns the first index of v in seq, or -1 if v is not present.
func Max ¶
func Max[T constraints.Ordered](seq iter.Seq[T]) (T, bool)
Max returns the maximum element of seq.
func Min ¶
func Min[T constraints.Ordered](seq iter.Seq[T]) (T, bool)
Min returns the minimum element of seq.
func RangeByStep ¶
func RangeByStep[T constraints.Integer | constraints.Float](start, end, step T) iter.Seq[T]
RangeByStep returns a sequence of integers from start (inclusive) to end (exclusive) by step. If step is zero, the sequence will be empty.
func RangeFrom ¶
func RangeFrom[T constraints.Integer | constraints.Float](start, step T) iter.Seq[T]
RangeFrom returns a sequence of integers from start (inclusive) to infinity by step. If step is zero, the sequence will be empty.
func Zip ¶
Zip returns an iterator that iterates x and y in parallel, yielding Zipped values of successive elements of x and y. If one sequence ends before the other, the iteration continues with Zipped values in which either Ok1 or Ok2 is false, depending on which sequence ended first.
Zip is a useful building block for adapters that process pairs of sequences. For example, Equal can be defined as:
func Equal[V comparable](x, y Seq[V]) bool { for z := range Zip(x, y) { if z.Ok1 != z.Ok2 || z.V1 != z.V2 { return false } } return true }