Documentation
¶
Index ¶
- func All[T any](s []T, f func(T) bool) bool
- func Any[T any](s []T, f func(T) bool) bool
- func Chunks[T any](ts []T, size int) [][]T
- func ChunksToSeq[T any](ts []T, size int) iter.Seq[[]T]
- func Count[T any](s []T, f func(T) bool) int
- func Filter[T any](s []T, f func(T) bool) []T
- func FilterInPlace[T any](s []T, f func(T) bool) []T
- func FilterToSeq[T any](s []T, f func(T) bool) iter.Seq[T]
- func Find[T any](s []T, f func(T) bool) (int, T)
- func FindPtr[T any](s []T, f func(*T) bool) *T
- func GoInChunks[T any](ts []T, size int, f func([]T) error) error
- func GroupBy[T any, K comparable](slice []T, key func(T) K) map[K][]T
- func GroupByKV[T any, K comparable, V any](slice []T, kv func(T) (K, V)) map[K][]V
- func Map[T any, U any](is []T, f func(T) U) []U
- func MapMinMax[T any, K cmp.Ordered](s []T, f func(T) K) (K, K)
- func MapToSeq[T any, U any](is []T, f func(T) U) iter.Seq[U]
- func MapUnique[T any, U comparable](is []T, f func(T) U) []U
- func MapUniqueToSeq[T any, U comparable](is []T, f func(T) U) iter.Seq[U]
- func MinMax[T any](s []T, compare func(T, T) int) (T, T)
- func Partition[T any](slice []T, predicate func(T) bool) (trueGroup []T, falseGroup []T)
- func PartitionConsEq[T any](slice []T, eq func(a, b T) bool) [][]T
- func PartitionConsEqToSeq[T any](slice []T, eq func(a, b T) bool) iter.Seq[[]T]
- func PartitionToSeq[T any](slice []T, predicate func(T) bool) (trueGroup iter.Seq[T], falseGroup iter.Seq[T])
- func Reduce[T any, A any](s []T, a A, f func(T, A) A) A
- func Sort[T any](s []T, compare func(T, T) int)
- func Sorted[T any](s []T, compare func(T, T) int) []T
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func All ¶
All returns true if all elements in s satisfy the predicate f. If s is empty or nil, All returns true.
func Any ¶
Any returns true if any element in the slice satisfies the predicate, false otherwise. If the slice is empty or nil, Any returns false.
func ChunksToSeq ¶
ChunksToSeq returns a sequence of chunks of the input slice, each of given size at most.
func Filter ¶
Filter returns a new slice containing only the elements of slice 's' that satisfy the predicate f.
func FilterInPlace ¶
FilterInPlace removes all elements from slice 's' that do not satisfy the predicate f and returns the modified slice.
func FilterToSeq ¶
FilterToSeq returns a new sequence containing only the elements of slice 's' that satisfy the predicate f.
func Find ¶
Find returns the index and the element of the first element in the slice that satisfies the predicate f. If no element satisfies the predicate, Find returns -1 and the zero value of the element type.
func FindPtr ¶ added in v1.0.13
FindPtr returns the pointer to the first element in the slice that satisfies the predicate f. If no element satisfies the predicate, FindPtr returns nil.
func GoInChunks ¶
GoInChunks calls the given function for each chunk of the input slice, each of given size at most.
func GroupBy ¶
func GroupBy[T any, K comparable](slice []T, key func(T) K) map[K][]T
GroupBy groups elements of slice by key K calculated from the slice elements.
func GroupByKV ¶ added in v1.0.5
func GroupByKV[T any, K comparable, V any](slice []T, kv func(T) (K, V)) map[K][]V
GroupByKV groups values V by key K where V and K are calculated from the slice elements.
func MapMinMax ¶ added in v1.0.12
MapMinMax applies a function to each element of the slice and finds the minimum and maximum values based on the results of that function.
func MapUnique ¶
func MapUnique[T any, U comparable](is []T, f func(T) U) []U
MapUnique applies a function to each element of a slice and returns a new slice with unique elements.
func MapUniqueToSeq ¶
func MapUniqueToSeq[T any, U comparable](is []T, f func(T) U) iter.Seq[U]
MapUniqueToSeq applies a function to each element of a slice and returns a new sequence with unique elements.
func Partition ¶
Partition returns two slices, the first slice contains all elements that satisfy the predicate, and the second slice contains all elements that do not satisfy the predicate.
func PartitionConsEq ¶
PartitionConsEq returns a slice of slices of consecutive equal elements.
func PartitionConsEqToSeq ¶
PartitionConsEqToSeq returns a sequence of slices of consecutive equal elements.
func PartitionToSeq ¶
func PartitionToSeq[T any](slice []T, predicate func(T) bool) (trueGroup iter.Seq[T], falseGroup iter.Seq[T])
PartitionToSeq returns two sequences, the first sequence contains all elements that satisfy the predicate, and the second sequence contains all elements that do not satisfy the predicate.
func Reduce ¶
Reduce applies a function against an accumulator and each element in the slice (from left to right) to reduce it to a single value.
Types ¶
This section is empty.