Documentation
¶
Index ¶
- func All[T any](seq iter.Seq[T], pred Pred[T]) bool
- func Any[T any](seq iter.Seq[T], pred Pred[T]) bool
- func Bool[T bool](v bool) bool
- func Chain[T any](seqs ...iter.Seq[T]) iter.Seq[T]
- func Contains[T any](seq iter.Seq[T], value T, eq Eq[T]) bool
- func Count[T constraints.Integer](start T) iter.Seq[T]
- func Create[T any](fn CreateFunc[T]) iter.Seq[T]
- func Cycle[T any](v T, vs ...T) iter.Seq[T]
- func DropWhile[T any](seq iter.Seq[T], pred Pred[T]) iter.Seq[T]
- func Enumerate[T any](seq iter.Seq[T], start int) iter.Seq2[int, T]
- func Equ[T comparable](v1, v2 T) bool
- func Equal[T any](seq1, seq2 iter.Seq[T], eq Eq[T]) bool
- func Filter[T any](seq iter.Seq[T], pred Pred[T]) iter.Seq[T]
- func Find[T any](seq iter.Seq[T], value T, eq Eq[T]) iter.Seq2[int, T]
- func First[U, V any](seq iter.Seq2[U, V]) iter.Seq[U]
- func Map[T, U any](seq iter.Seq[T], fn MapFunc[T, U]) iter.Seq[U]
- func Map2[T, U, V any](seq1 iter.Seq[T], seq2 iter.Seq[U], fn Map2Func[T, U, V]) iter.Seq[V]
- func Map3[T, U, V, W any](seq1 iter.Seq[T], seq2 iter.Seq[U], seq3 iter.Seq[V], fn Map3Func[T, U, V, W]) iter.Seq[W]
- func Max[T any](seq iter.Seq[T], cmp Cmp[T]) T
- func Merge[U, V any](seq1 iter.Seq[U], seq2 iter.Seq[V]) iter.Seq2[U, V]
- func Min[T any](seq iter.Seq[T], cmp Cmp[T]) T
- func New[T any](vs ...T) iter.Seq[T]
- func Purge[T any](seq iter.Seq[T], pred Pred[T]) iter.Seq[T]
- func Reduce[T, U any](seq iter.Seq[T], init U, fn ReduceFunc[T, U]) U
- func Repeat[T any](v T, n int) iter.Seq[T]
- func Second[U, V any](seq iter.Seq2[U, V]) iter.Seq[V]
- func Split[U, V any](seq iter.Seq2[U, V]) (iter.Seq[U], iter.Seq[V])
- func TakeWhile[T any](seq iter.Seq[T], pred Pred[T]) iter.Seq[T]
- func Unique[T any](seq iter.Seq[T], cmp Cmp[T]) iter.Seq[T]
- func Unzip[U, V any](seq iter.Seq[Tuple[U, V]]) (iter.Seq[U], iter.Seq[V])
- func Unzip3[U, V, W any](seq iter.Seq[Tuple3[U, V, W]]) (iter.Seq[U], iter.Seq[V], iter.Seq[W])
- func Zip[U, V any](seq1 iter.Seq[U], seq2 iter.Seq[V]) iter.Seq[Tuple[U, V]]
- func Zip3[U, V, W any](seq1 iter.Seq[U], seq2 iter.Seq[V], seq3 iter.Seq[W]) iter.Seq[Tuple3[U, V, W]]
- type Cmp
- type CreateFunc
- type Eq
- type ExtremaS
- type Map2Func
- type Map3Func
- type MapFunc
- type Pred
- type ReduceFunc
- type Tuple
- type Tuple3
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Count ¶
func Count[T constraints.Integer](start T) iter.Seq[T]
Count returns an iter.Seq that counts from the start value upward.
func Create ¶
func Create[T any](fn CreateFunc[T]) iter.Seq[T]
Create returns a new iter.Seq with the values created bei the given CreateFunc function.
Example: create an endless sequence with random ints.
func RandomInt(n int) iter.Seq[int] {
if n == 0 {
return Create(func() (int, bool) { return rand.Int(), false })
}
return Create(func() (int, bool) { return rand.IntN(n), false })
}
func DropWhile ¶
DropWhile drops values from seq as long as pred returns true and returns the rest in a new iter.Seq.
func Map2 ¶
Map2 maps values in two sequences using a mapping function. It stops when the shortest sequence is exhausted.
func Map3 ¶
func Map3[T, U, V, W any](seq1 iter.Seq[T], seq2 iter.Seq[U], seq3 iter.Seq[V], fn Map3Func[T, U, V, W]) iter.Seq[W]
Map3 maps values in three sequences using a mapping function. It stops when the shortest sequence is exhausted.
func Merge ¶
Merge returns an iter.Seq2 combining two [iter.Seq]s. It stops when the shortest sequence is exhausted.
func Reduce ¶
func Reduce[T, U any](seq iter.Seq[T], init U, fn ReduceFunc[T, U]) U
Reduce reduces seq to a single value by accumulating the values in seq using function fn. The first argument to fn is the accumulated value (starting with init).
func TakeWhile ¶
TakeWhile takes values from seq as long as pred returns true and returns them in a new iter.Seq.
Types ¶
type Cmp ¶
Compare function.
Returns -1 if the first value is less then the second, 0 if both are equal, 1 if the first value is greater then the second.
type CreateFunc ¶
Function type for use with Create. To stop the creation of more values, the bool return value must be true.
type Map2Func ¶
type Map2Func[T, U, V any] func(x T, y U) V
A Map2Func maps two values to another value.
type Map3Func ¶
type Map3Func[T, U, V, W any] func(x T, y U, z V) W
A Map3Func maps three values to another value.