sliceutil

package
v0.0.0-...-57f3b98 Latest Latest
Warning

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

Go to latest
Published: May 16, 2024 License: BSD-3-Clause Imports: 1 Imported by: 0

README

sliceutil

Package sliceutil provides functionality not available in the new standard slices package (since go 1.21).

Documentation

Overview

package sliceutil covers utilities not found in https://pkg.golang.ir/golang.org/x/exp/slices

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func All

func All[T any](t []T, fn func(i int) bool) bool

Any returns true if all of the result returns true.

func Any

func Any[T any](t []T, fn func(i int) bool) bool

Any returns true if any of the result returns true.

func Dedup

func Dedup[T comparable](t []T) []T

func DedupFunc

func DedupFunc[T any, K comparable](t []T, fn func(i int) K) []T

func Filter

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

func Find

func Find[T any](t []T, fn func(i int) bool) (T, bool)
func Head[T any](t []T) (v T, ok bool)

func Map

func Map[K, V any](ks []K, fn func(i int) V) []V

func MapError

func MapError[K, V any](ks []K, fn func(i int) (V, error)) ([]V, error)

func None

func None[T any](t []T, fn func(i int) bool) bool

None returns true if none of the result returns true.

func Some

func Some[T any](t []T, fn func(i int) bool) bool

Some is an alias to Any.

func Sum

func Sum[T constraints.Integer](n []T) (total T)

func Tail

func Tail[T any](t []T) (v T, ok bool)

func Take

func Take[T any](t []T, n int) []T

Types

This section is empty.

Jump to

Keyboard shortcuts

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