Documentation
¶
Index ¶
- func All[T comparable](slice []T, matches func(elem T) bool) bool
- func Any[T comparable](slice []T, matches func(elem T) bool) bool
- func Chunk[T any](slice []T, size int) [][]T
- func Compact[T comparable](slice []T) []T
- func Contains[T comparable](slice []T, value T) bool
- func ContainsAll[T comparable](slice []T, values ...T) bool
- func ContainsAny[T comparable](slice []T, values ...T) bool
- func Distinct[T comparable](slice []T, normalizeMapKey func(T) T) []T
- func Filter[T comparable](slice []T, matches func(elem T) bool) []T
- func First[T comparable](slice []T, matches func(elem T) bool) T
- func ForEach[T any](slice []T, f func(elem T, index int))
- func IndexOf[T comparable](slice []T, matches func(elem T) bool) int
- func Insert[T any](slice []T, item T, i int) []T
- func Last[T comparable](slice []T, matches func(elem T) bool) T
- func LastIndexOf[T comparable](slice []T, matches func(elem T) bool) int
- func Map[T comparable](slice []T, mapper func(elem T) T) []T
- func Max[T constraints.Ordered](slice []T) T
- func Min[T constraints.Ordered](slice []T) T
- func Prepend[T any](slice []T, item T) []T
- func Reduce[T comparable, TResult any](slice []T, seed TResult, reducer func(acc TResult, elem T, index int) TResult) TResult
- func Reverse[T any](slice []T) []T
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func All ¶
func All[T comparable](slice []T, matches func(elem T) bool) bool
All returns true if all items in slice are matched by matches func;
func Any ¶
func Any[T comparable](slice []T, matches func(elem T) bool) bool
Any returns true if at least one item in slice is matched by matches func.
func Compact ¶
func Compact[T comparable](slice []T) []T
Compact removes all empty/zero values from slice.
func Contains ¶
func Contains[T comparable](slice []T, value T) bool
Contains returns true if value exists in slice.
func ContainsAll ¶
func ContainsAll[T comparable](slice []T, values ...T) bool
ContainsAll returns true if all values exist in slice.
func ContainsAny ¶
func ContainsAny[T comparable](slice []T, values ...T) bool
Contains returns true if any values exist in slice.
func Distinct ¶
func Distinct[T comparable](slice []T, normalizeMapKey func(T) T) []T
Distinct returns a list of unique items in slice. It uses a map to determine uniqueness and the normalizeMapKey func to normalize the key for comparison.
func Filter ¶
func Filter[T comparable](slice []T, matches func(elem T) bool) []T
Filter returns a list of items in slice that are matched by matches func.
func First ¶
func First[T comparable](slice []T, matches func(elem T) bool) T
First returns the first item in slice that is matched by matches func.
func IndexOf ¶
func IndexOf[T comparable](slice []T, matches func(elem T) bool) int
IndexOf returns the index of the first item in slice that is matched by matches func.
func Last ¶
func Last[T comparable](slice []T, matches func(elem T) bool) T
Last returns the last item in slice that is matched by matches func.
func LastIndexOf ¶
func LastIndexOf[T comparable](slice []T, matches func(elem T) bool) int
LastIndexOf returns the index of the last item in slice that is matched by matches func.
func Map ¶
func Map[T comparable](slice []T, mapper func(elem T) T) []T
func Min ¶
func Min[T constraints.Ordered](slice []T) T
Min returns the smallest item in slice. Min returns the smallest item in slice.
func Reduce ¶
func Reduce[T comparable, TResult any](slice []T, seed TResult, reducer func(acc TResult, elem T, index int) TResult) TResult
Types ¶
This section is empty.