Documentation
¶
Overview ¶
Package basics provides utility functions
Index ¶
- func Equal[T comparable](l, r []T) bool
- func EqualFunc[T any](l, r []T, cmp func(T, T) bool) bool
- func Filter[T any](s []T, f func(T) bool) []T
- func Find[T any](s []T, f func(T) bool) (T, bool)
- func IndexedMap[In, Out any](s []In, fn func(elem In, idx int) Out) []Out
- func Map[In, Out any](s []In, f func(In) Out) []Out
- func MapKeys[K comparable, V any](m map[K]V) []K
- func MapValues[K comparable, V any](m map[K]V) []V
- func SortedFunc[T any](s []T, cmp func(l, r T) int) []T
- func SortedKeys[K cmp.Ordered, V any](m map[K]V) []K
- func SortedKeysFunc[K comparable, V any](m map[K]V, cmp func(l, r K) int) []K
- func SortedMap[In any, Out cmp.Ordered](s []In, f func(In) Out) []Out
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Equal ¶
func Equal[T comparable](l, r []T) bool
Equal compares two slices of the same type for equality
func Filter ¶
Filter returns a new slice containing only the elements that satisfy the provided predicate function
func IndexedMap ¶
IndexedMap returns a new slice by applying the provided mapping function to each element of the input slice, passing the index of each element as a second argument
func Map ¶
func Map[In, Out any](s []In, f func(In) Out) []Out
Map returns a new slice by applying the provided mapping function to each element of the input slice
func MapKeys ¶
func MapKeys[K comparable, V any](m map[K]V) []K
MapKeys returns the keys of the provided map as a slice
func MapValues ¶
func MapValues[K comparable, V any](m map[K]V) []V
MapValues returns the values of the provided map as a slice
func SortedFunc ¶
SortedFunc returns a sorted copy of the slice using the provided comparison function
func SortedKeys ¶
SortedKeys returns the keys of the provided map as a sorted slice
func SortedKeysFunc ¶
func SortedKeysFunc[K comparable, V any](m map[K]V, cmp func(l, r K) int) []K
SortedKeysFunc returns the keys of the provided map as a sorted slice using the provided comparison function
Types ¶
This section is empty.