slicex

package
v0.0.31 Latest Latest
Warning

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

Go to latest
Published: Aug 25, 2023 License: MIT Imports: 1 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ContainsFunc

func ContainsFunc[E any](s []E, fn func(E) bool) bool

ContainsFunc returns true if s contains an element for which f returns true.

func Copy added in v0.0.2

func Copy[S ~[]E, E any](s S) S

Copy returns a copy of s, with each element copied separately. For a shallow copy, call slices.Clone instead.

func Ensure added in v0.0.5

func Ensure[S ~[]E, E any](s S) S

Ensure returns the slice s if it is non-nil. Otherwise it returns a new initialized slice.

func Filter

func Filter[S ~[]E, E any](s S, fn func(E) bool) S

Filter returns a new slice containing all elements of s for which f returns true.

func Map

func Map[E, R any](s []E, fn func(E) R) []R

Map returns a new slice containing the results of applying f to each element of s.

Types

This section is empty.

Jump to

Keyboard shortcuts

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