Documentation
¶
Overview ¶
A package to operate on slices.
Index ¶
- func Any[T any](fn func(v T) bool, slice ...T) bool
- func Append[T any](slice []T, elements ...T) []T
- func Cut[T comparable](i, j int, a ...T) []T
- func Delete[T comparable](i int, a ...T) []T
- func FailForEach[T any](fn func(v T, i int) error, slice ...T) error
- func Filter[T any](fn func(v T) bool, slice ...T) []T
- func Find[T any](fn func(v T) bool, slice ...T) (T, bool)
- func FindIndex[T any](fn func(v T) bool, slice ...T) (int, bool)
- func First[T any](slice ...T) T
- func ForEach[T any](fn func(v T, i int), slice ...T)
- func GreaterThen[T any](i int, elements ...T) bool
- func In[T comparable](val T, slice ...T) bool
- func Index[T any](fn func(v T) bool, slice ...T) int
- func Insert[T comparable](x T, idx int, a ...T) []T
- func KeyValue[K comparable, V any](m map[K]V) []string
- func Last[T any](slice ...T) T
- func Len[T any](i int, elements ...T) bool
- func LessThen[T any](i int, elements ...T) bool
- func Limit[T any](limit int, slice ...T) []T
- func Map[T1 any, T2 any](fn func(v T1) T2, slice ...T1) []T2
- func Pop[T comparable](a ...T) (T, []T)
- func Push[T comparable](x T, a ...T) []T
- func Range(from, to int) []int
- func Reverse[T any](slice []T) []T
- func Size[T any](size int, slice ...T) bool
- func Slice[T any](slice []any) []T
- func Unique[T1 any, T2 comparable](fn func(v T1) T2, slice ...T1) []T1
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Cut ¶
func Cut[T comparable](i, j int, a ...T) []T
Cut removes an element from a slice at a given position.
func Delete ¶
func Delete[T comparable](i int, a ...T) []T
Delete removes an element from a slice by value.
func FailForEach ¶ added in v0.7.8
FailForEach applies a function to all elements in a slice and returns an error if the function returns false for any element.
func FindIndex ¶ added in v0.7.6
FindIndex returns the index of the first element in a slice that satisfies a predicate.
func GreaterThen ¶ added in v0.7.6
GreaterThen checks if the first slice is greater than the second slice.
func Insert ¶
func Insert[T comparable](x T, idx int, a ...T) []T
Insert adds an element at a given position in a slice.
func KeyValue ¶ added in v0.7.8
func KeyValue[K comparable, V any](m map[K]V) []string
KeyValue returns a string slice of key-value pairs from a map.
func Reverse ¶
func Reverse[T any](slice []T) []T
Reverse reverses the order of elements in a slice.
func Unique ¶
func Unique[T1 any, T2 comparable](fn func(v T1) T2, slice ...T1) []T1
Unique returns a slice with all duplicate elements removed.
Types ¶
This section is empty.