util

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: May 19, 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[T any](s []T, f func(T) bool) bool

All returns whether all elements in the given slice match the given predicate

func Any

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

Any returns whether any element in the given slice matches the given predicate

func Contains

func Contains[T comparable](s []T, v T) bool

Contains returns whether the given slice contains the given element

func ExpandHome

func ExpandHome(path *string)

func FindFirst

func FindFirst[T any](s []T, f func(T) bool) *T

FindFirst return a reference to the first element of the slice that matches the predicate. It returns nil if the slice is nil or empty or if no item matches the predicate.

func Join

func Join(arr []string, joiner string) string

func Keys

func Keys[K comparable, V any](m map[K]V) []K

func Map

func Map[TIn any, TOut any](s []TIn, f func(TIn) TOut) []TOut

func Max

func Max(arr []int) int

func Pad

func Pad(s string, maxLen int) string

func Transpose

func Transpose[T any](slice [][]T) [][]T

Transpose returns the matrix transposed from (nxm) to (mxn)

func Values

func Values[K comparable, V any](m map[K]V) []V

func Where

func Where[T any](s []T, f func(T) bool) []T

Where returns all elements in a slice that match the given predicate

Types

This section is empty.

Jump to

Keyboard shortcuts

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