lavaslices

package
v1.2.5 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 2, 2024 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Average

func Average[T Number](slice []T) T

func Concat

func Concat[T any](s ...[]T) []T

func Contains

func Contains[T comparable](slice []T, elem T) bool

func Filter

func Filter[T any](slice []T, filter func(T) bool) []T

func Intersection

func Intersection[T comparable](arrays ...[]T) []T

func IsSubset

func IsSubset[T comparable](subset, superset []T) bool

func Map

func Map[T, V any](slice []T, filter func(T) V) []V

func Max

func Max[T constraints.Ordered](s []T) (m T)

func Median

func Median[T Number](slice []T) T

func Min

func Min[T constraints.Ordered](s []T) (m T)

func Percentile

func Percentile[T Number](slice []T, rank float64) T

func Remove

func Remove[T comparable](slice []T, elem T) ([]T, bool)

Remove removes the first instance (if exists) of elem from the slice, and returns the new slice and indication if removal took place.

func Slice

func Slice[T any](v ...T) []T

func SplitGenericSliceIntoChunks added in v1.0.4

func SplitGenericSliceIntoChunks[T any](arr []T, chunkSize int) [][]T

splitSliceGeneric splits a slice into smaller slices of at most chunkSize length. for example len(arr) == 1400 and chunk size 500 will return [500, 500, 400]

func Stability

func Stability[T Number](slice []T, compare T) float64

the bigger it is the more unstable the values in slice from the given argument "compare"

func Union

func Union[T comparable](arrays ...[]T) []T

func UnionByFunc

func UnionByFunc[T ComparableByFunc](arrays ...[]T) []T

func UnorderedEqual

func UnorderedEqual[T comparable](slices ...[]T) bool

func Variance

func Variance[T Number](slice []T, mean T) T

Types

type ComparableByFunc

type ComparableByFunc interface {
	Differentiator() string
}

type Number

type Number interface {
	constraints.Float | constraints.Integer
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL