slicey

package
v0.1.19 Latest Latest
Warning

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

Go to latest
Published: May 23, 2024 License: Apache-2.0 Imports: 1 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func All added in v0.1.10

func All[T any](vs []T, f func(v T) bool) bool

All returns true if and only if f returns true for all vs.

func Contains

func Contains[T comparable](vs []T, needle T) bool

Contains returns true if needle exists in vs.

func ContainsFunc

func ContainsFunc[T any](vs []T, f func(v T) bool) bool

ContainsFunc returns true if f returns true for any element in vs.

func Equal

func Equal[T comparable](vs1 []T, vs2 []T) bool

Equal returns true if vs1 and vs2 are equal (contain the same elements in the same order.)

func EqualFunc

func EqualFunc[T any](vs1 []T, vs2 []T, f func(v1 T, v2 T) bool) bool

EqualFunc returns true if vs1 and vs2 are of the same length and f returns true for all pairs from vs1 and vs2 to be compared.

func Filter added in v0.1.8

func Filter[T any](vs []T, f func(T) bool) []T

Filter returns all elements from vs for which f returns true.

func Find

func Find[T any](vs []T, f func(T) bool) (T, bool)

func Map added in v0.1.3

func Map[T any, U any](vs []T, f func(T) U) []U

Map uses f to map values from type T to type V.

func Random

func Random[T any](vs []T) T

Random returns a random element from vs. If vs is empty or nil, the default value of T is returned.

func Unique

func Unique[T comparable](vs []T) []T

Unique returns a new list containing unique values from v.

Types

This section is empty.

Jump to

Keyboard shortcuts

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