slice

package
v0.19.4 Latest Latest
Warning

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

Go to latest
Published: May 8, 2024 License: Apache-2.0 Imports: 0 Imported by: 0

Documentation

Overview

Package slice contains generic Slice helpers; Some of this code is sourced from https://github.com/luraim/fun (Apache v2)

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func All

func All[T any](s []T, fn func(T) bool) bool

All returns true if all elements return true for given predicate

func Any

func Any[T any](s []T, fn func(T) bool) bool

Any returns true if at least one element returns true for given predicate

func Filter

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

Filter returns a new slice containing only the elements for which the predicate returns true

func Map

func Map[From, To any](in []From, f func(From) To) []To

Map applies a function to each element of a slice and returns a new slice

func MapWithError

func MapWithError[From, To any](in []From, f func(From) (To, error)) (result []To, err error)

MapWithError applies a function to each element of a slice and returns a new slice, or an error

Types

This section is empty.

Jump to

Keyboard shortcuts

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