sliceutil

package
v0.2.2 Latest Latest
Warning

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

Go to latest
Published: Feb 23, 2023 License: Apache-2.0 Imports: 0 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Any added in v0.2.0

func Any[T any](ts []T) (T, bool)

Any returns an arbitrary element of the slice. If the slice is not empty, the second return value is true. Otherwise, Any returns the zero value of the slice's element type and false.

func Filter added in v0.2.0

func Filter[T any](ts []T, f func(i int, t T) bool) []T

func Generate

func Generate[T any](n int, f func(i int) T) []T

func Repeat

func Repeat[T any](value T, n int) []T

Repeat returns a slice with value repeated n times.

func Transform added in v0.2.0

func Transform[T, R any](ts []T, f func(i int, t T) R) []R

Types

This section is empty.

Jump to

Keyboard shortcuts

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