Documentation ¶
Overview ¶
Package generic contains all generic functions. Please use https://github.com/samber/lo
Index ¶
- func Contains[T comparable](s []T, v T) bool
- func Filter[T any](s []T, f func(T) bool) []T
- func FilterNew[T any](s []T, f func(T) bool) []T
- func Intersection[A comparable](a []A, b []A) (intersection []A)
- func Map[T any](s []T, f func(T) T) []T
- func MapNew[T any](s []T, f func(T) T) []T
- func Reduce[T any](s []T, init T, f func(T, T) T) T
- func RemoveEmpty[T comparable](slIN []T) []T
- func Reverse[T any](s []T) []T
- func ToAnySlice[T any](slice []T) []any
- func ToStringSlice[T ~string](strs ...T) []string
- func Window[S any](elements []S, size int) [][]S
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Contains ¶
func Contains[T comparable](s []T, v T) bool
func FilterNew ¶
FilterNew filters slice s with predicate f. Returns a new slice, leaving s untouched. Might return a nil slice.
func Intersection ¶
func Intersection[A comparable](a []A, b []A) (intersection []A)
Intersection returns a list of common elements present in both arrays. The elements in the output can be in any order.
func Map ¶
func Map[T any](s []T, f func(T) T) []T
Map maps function f to each element of slice "s". It changes slice "s".
func MapNew ¶
func MapNew[T any](s []T, f func(T) T) []T
MapNew maps function f to each slice element and returns a new slice, leaving input slice "s" untouched.
func RemoveEmpty ¶
func RemoveEmpty[T comparable](slIN []T) []T
func ToAnySlice ¶
func ToStringSlice ¶
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.