slice

package
v0.11.0 Latest Latest
Warning

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

Go to latest
Published: Mar 10, 2025 License: MIT Imports: 0 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Filter

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

Filter returns a new slice containing only the elements of the slice that satisfy the predicate.

func FindFunc added in v0.9.3

func FindFunc[T any](data []T, f func(T) bool) (T, bool)

FindFunc returns the first element in the slice that satisfies the predicate.

It returns the default value for the type and false if no element satisfies the predicate.

func FindIFunc added in v0.9.3

func FindIFunc[T any](data []T, f func(T) bool) (int, bool)

FindIFunc returns the index of the first element in the slice that satisfies the predicate.

It returns -1 and false if no element satisfies the predicate

func Intersect

func Intersect[T comparable](a, b []T) []T

Intersect returns the intersection of two comparable slices.

func Map

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

Map applies a function to each element of a slice and returns a new slice with the results.

Types

This section is empty.

Jump to

Keyboard shortcuts

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