slices

package
v0.0.0-...-9d82e64 Latest Latest
Warning

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

Go to latest
Published: Apr 5, 2023 License: MIT Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func All

func All[S ~[]T, T any](items S, f func(item T) bool) bool

All returns true if the function 'f' evaluates to true for all elements in the slice 'items'.

func Any

func Any[S ~[]T, T any](items S, f func(item T) bool) bool

Any returns true if the function 'f' evaluates to true for any element of the slice 'items'

func Count

func Count[S ~[]T, T comparable](items S, item T) int

Count returns the number of occurrences for an element in a slice.

func CountBy

func CountBy[S ~[]T, T any](items S, f func(item T) bool) int

CountBy returns the number of elements in slice 'items' for which the function 'f' evaluates to true.

func Filter

func Filter[S ~[]T, T any](items S, f func(item T) bool) S

Filter returns a new slice with the elements from the 'items' slice for which the function 'f' returned true.

func ForEach

func ForEach[S ~[]T, T any](items S, f func(item T))

ForEach calls the function 'f' for each element in the slice 'items'.

func Map

func Map[S ~[]T, T any, U any](items S, f func(item T) U) []U

Map calls the function 'f' for each element of the 'items' slice and returns a new slice with the results.

func Max

func Max[S ~[]T, T constraints.Ordered](items S) (T, error)

Max returns the maximum element from the given slice.

func Min

func Min[S ~[]T, T constraints.Ordered](items S) (T, error)

Min returns the minimum element from the given slice.

func Reduce

func Reduce[S ~[]T, T any, U any](items S, acc U, f func(item T, acc U) U) U

Reduce applies the function 'f' to every element in the slice 'items' and to accumulator 'acc' and returns the accumulator.

Types

This section is empty.

Jump to

Keyboard shortcuts

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