Documentation ¶
Index ¶
- func All[S Seq[E], E any](seq S, pred func(E) bool) (res bool)
- func And[S Seq[bool]](seq S) bool
- func Any[S Seq[E], E any](seq S, pred func(E) bool) (res bool)
- func AppendTo[S Seq[E], E any, Es ~[]E](seq S, slice Es) Es
- func Count[S Seq[E], E any](seq S) int
- func First[S Seq[E], E any](seq S) (first E, hasFirst bool)
- func ForEach[S Seq[E], E any](seq S, yield func(E))
- func ForEachUntilWithIndex[S Seq[E], E any](seq S, yield func(int, E) bool)
- func ForEachWhile[S Seq[E], E any](seq S, yield func(E) bool)
- func ForEachWhileWithIndex[S Seq[E], E any](seq S, yield func(int, E) bool)
- func ForEachWithIndex[S Seq[E], E any](seq S, yield func(int, E))
- func IsEmpty[S Seq[E], E any](seq S) bool
- func Last[S Seq[E], E any](seq S) (last E, hasLast bool)
- func Or[S Seq[bool]](seq S) bool
- func Reduce[S Seq[E], E any](seq S, op func(E, E) E) (res E)
- func SeededReduce[S Seq[E], E any, A any](seq S, seed A, op func(A, E) A) (res A)
- func Sum[S Seq[E], E Summable](seq S) E
- func ToSet[S Seq[E], E comparable](seq S) (res map[E]bool)
- func ToSlice[S Seq[E], E any](seq S) (res []E)
- type FiniteSeq
- type Lener
- type Pair
- type Seq
- func AsSeq[S Seq[E], E any](seq S) Seq[E]
- func Concat[E any](seqs ...Seq[E]) Seq[E]
- func Cycle[S Seq[E], E any](seq S) Seq[E]
- func Empty[E any]() Seq[E]
- func Enumerate[S Seq[E], E any](seq S) Seq[Pair[int, E]]
- func Filter[S Seq[E], E any](seq S, pred func(E) bool) Seq[E]
- func FilterWithIndex[S Seq[E], E any](seq S, pred func(int, E) bool) Seq[E]
- func Flatten[SS Seq[S], S Seq[E], E any](seq SS) Seq[E]
- func FromSlice[Es ~[]E, E any](s Es) Seq[E]
- func FromSlicePtrs[Es ~[]E, E any](s Es) Seq[*E]
- func FromValues[E any](values ...E) Seq[E]
- func Generate[E any](gen func() E) Seq[E]
- func GenerateWithIndex[E any](gen func(idx int) E) Seq[E]
- func Intersperse[S Seq[E], E any](seq S, val E) Seq[E]
- func Map[S Seq[Src], Src any, Dst any](seq S, mapfn func(Src) Dst) Seq[Dst]
- func MapWithIndex[S Seq[Src], Src any, Dst any](seq S, mapfn func(int, Src) Dst) Seq[Dst]
- func PartialSums[S Seq[E], E Summable](seq S) Seq[E]
- func Reductions[S Seq[E], E any](seq S, op func(E, E) E) Seq[E]
- func Reject[S Seq[E], E any](seq S, pred func(E) bool) Seq[E]
- func RejectWithIndex[S Seq[E], E any](seq S, pred func(int, E) bool) Seq[E]
- func Repeat[E any](e E) Seq[E]
- func RepeatN[E any](e E, n int) Seq[E]
- func RoundRobin[E any](seqs ...Seq[E]) Seq[E]
- func SeededReductions[S Seq[E], E any, A any](seq S, seed A, op func(A, E) A) Seq[A]
- func SeqFunc[E any](fn func(yield func(E) bool)) Seq[E]
- func Skip[S Seq[E], E any](s S, n int) Seq[E]
- func SkipWhile[S Seq[E], E any](s S, pred func(E) bool) Seq[E]
- func SlidingWindow[S Seq[E], E any](seq S, count int, skip int) Seq[[]E]
- func Take[S Seq[E], E any](s S, n int) Seq[E]
- func TakeWhile[S Seq[E], E any](s S, pred func(E) bool) Seq[E]
- func ZipMany[E any](seqs ...Seq[E]) Seq[[]E]
- func ZipWith[S1 Seq[E1], S2 Seq[E2], E1 any, E2 any, T any](seq1 S1, seq2 S2, merge func(E1, E2) T) Seq[T]
- type Summable
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func All ¶ added in v0.5.0
All returns true if the specified predicate returns true for all elements of the specified sequence
Application to an infinite sequence will block indefinitely.
func And ¶ added in v0.7.0
And returns true if all elements of the specified sequence are true, which includes the empty sequence
Application to an infinite sequence will block indefinitely.
func Any ¶ added in v0.5.0
Any returns true if the specified predicate returns true for any element of the specified sequence
Application to an infinite sequence will block indefinitely.
func AppendTo ¶ added in v0.6.0
AppendTo appends elements from the specified sequence to the slice(ish)
func Count ¶ added in v0.9.0
Count returns the number of elements in the specified sequence.
Application to an infinite sequence will block indefinitely.
func First ¶ added in v0.9.0
First returns the first element of the specified sequence and true, or the zero value of E and false if the sequence is empty.
func ForEach ¶
ForEach calls the specified function for each element of the specified sequence
Application to an infinite sequence will block indefinitely.
func ForEachUntilWithIndex ¶ added in v0.3.0
ForEachUntilWithIndex calls the specified function for each element of the specified sequence along with its index until the function returns `true`
func ForEachWhile ¶
ForEachWhile calls the specified function for each element of the specified sequence while the function returns `true`
func ForEachWhileWithIndex ¶ added in v0.3.0
ForEachWhileWithIndex calls the specified function for each element of the specified sequence along with its index while the function returns `true`
func ForEachWithIndex ¶ added in v0.3.0
ForEachWithIndex calls the specified function for each element of the specified sequence along with its index
func IsEmpty ¶ added in v0.11.0
IsEmpty returns true if the specified sequence has no elements; otherwise, it returns false.
func Last ¶ added in v0.9.0
Last returns the last element of the specified sequence and true, or the zero value of E and false if the sequence is empty.
Application to an infinite sequence will block indefinitely.
func Or ¶ added in v0.7.0
Or returns true if any element of the specified sequence is true, which does not include the empty sequence
Application to an infinite sequence will block indefinitely.
func Reduce ¶
Reduce returns a value obtained by aggregating elements of the specified sequence using the specified operation.
If the specified sequence is empty, the zero value of E will be returned. If the specified sequence has a single element only, that element will be returned.
Application to an infinite sequence will block indefinitely.
func SeededReduce ¶ added in v0.9.0
SeededReduce returns a value obtained by applying the specified function to an accumlator value (initialized to the specified seed value) and successive elements of the sequence
Application to an infinite sequence will block indefinitely.
func Sum ¶ added in v0.6.0
Sum returns the sum of the specified sequence's elements.
Application to an infinite sequence will block indefinitely.
func ToSet ¶
func ToSet[S Seq[E], E comparable](seq S) (res map[E]bool)
ToSet returns a set (boolean valued map) created from the elements of the specified sequence
Application to an infinite sequence will block indefinitely.
Types ¶
type Lener ¶
type Lener interface { // Len returns the length of a collection // // This method returns an `int` to be consistent with the `len()` built-in function. Len() int }
Lener is an interface optionally implemented by sequences which have a finite length
type Seq ¶
type Seq[E any] interface { // ForEachUntil calls the specified function for each sequence element until the function returns `true` ForEachUntil(yield func(E) bool) }
Seq defines a minimal interface for a sequence of values
func Concat ¶ added in v0.2.0
Concat returns a sequence that is the concatenation of the specified sequences
func Cycle ¶ added in v0.2.0
Cycle returns an (almost always) infinite sequence that cyclically repeats the elements of the specified sequence
If the specified sequence is empty (or becomes empty at any point) the returned sequence becomes empty to avoid an unbreakable infinite loop.
func Filter ¶
Filter returns a sequence that only contains elements of the specified sequence for which the specified predicate returns `true`
func FilterWithIndex ¶ added in v0.3.0
FilterWithIndex returns a sequence that only contains elements of the specified sequence for which the specified predicate returns `true`
func Flatten ¶ added in v0.3.0
Flatten returns a sequence that is the concatenation of sequences contained by the specified sequence
The returned sequence never implements the Lener interface. Use Concat with ToSlice if you want the resulting sequence to implement Lener when possible.
func FromSlice ¶
FromSlice returns a sequence whose elemets are (copies of) the specified slice's elements
func FromSlicePtrs ¶ added in v0.7.0
FromSlicePtrs returns a sequence whose elements are pointers to the specified slice's elements
func FromValues ¶
FromValues returns a sequence made up of the specified values
func Generate ¶ added in v0.6.0
Generate returns a sequence whose elements are generated by calling the provided function
func GenerateWithIndex ¶ added in v0.6.0
GenerateWithIndex returns a sequence whose elements are generated by calling the provided function with the current index
func Intersperse ¶ added in v0.2.0
Intersperse returns a sequence whose elements are the same as the specified sequence's but interspersed with the specified value
func Map ¶
Map returns a sequence whose elements are obtained by applying the specified mapping function to elements of the specified sequence
func MapWithIndex ¶ added in v0.3.0
MapWithIndex returns a sequence whose elements are obtained by applying the specified mapping function to elements of the specified sequence along with their indices
func PartialSums ¶ added in v0.9.0
PartialSums returns a sequence of the partial sums of the specified sequence.
func Reductions ¶ added in v0.9.0
Reductions returns the sequence of intermediate values of the reduction of the specified sequence with the specified operation.
If the specified sequence is empty, the returned sequence will be empty. If the specified sequence has a single element only, a sequence containing only that element will be returned.
func Reject ¶ added in v0.10.0
Reject returns a sequence that only contains elements of the specified sequence for which the specified predicate returns `false`
func RejectWithIndex ¶ added in v0.10.0
RejectWithIndex returns a sequence that only contains elements of the specified sequence for which the specified predicate returns `false`
func RoundRobin ¶ added in v0.2.0
RoundRobin returns a sequence whose elements are obtained by alternately taking elements from the specified sequences in a round-robin fashion
func SeededReductions ¶ added in v0.9.0
SeededReductions returns the sequence of intermediate values of the reduction of the specified sequence by the specified operation starting with the specified seed value.
The returned sequence always has the seed value as its first element.
func SeqFunc ¶ added in v0.3.1
SeqFunc returns a sequence that has its ForEachUntil method implemented by the specified function
func Skip ¶
Skip returns a sequence that omits the first `n` number of elements of the specified sequence
If the source sequence has less than `n` elements the returned sequence will be empty
func SkipWhile ¶
SkipWhile returns a sequence that omits elements of the specified sequence while the specified predicate returns `true`
func SlidingWindow ¶ added in v0.4.0
SlidingWindow returns a sequence of windows (slices of count length) containing the elements of the specified sequence. Windows start after each other with a distance of skip.
func Take ¶
Take returns a sequence of the first `n` number of elements of the specified sequence
If the source sequence has less then `n` elements the returned sequence will also have only that many elements
func TakeWhile ¶
TakeWhile returns a sequence of the first elements of the specified sequence while the specified predicate returns `true`
TakeWhile(FromValues())