mr

package
v0.4.43 Latest Latest
Warning

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

Go to latest
Published: Sep 8, 2023 License: MIT Imports: 0 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Filter

func Filter[T any](arr []T, fn func(in T, index int) bool) []T

func Find added in v0.4.40

func Find[T any](arr []T, predict func(T) bool) T

Find returns the first element in the slice that satisfies the provided testing function. Otherwise zero value is returned.

func FindIndex added in v0.4.41

func FindIndex[T any](arr []T, predict func(T) bool) int

FindIndex returns the index of the first element in the slice that satisfies the provided testing function. Otherwise -1 is returned.

func FindP added in v0.4.40

func FindP[T any](arr []T, predict func(*T) bool) *T

FindP returns the first element in the slice that satisfies the provided testing function. Otherwise nil is returned.

func Flat added in v0.4.39

func Flat[T any](arr [][]T) []T

func Flats added in v0.4.39

func Flats[T any](arr ...[]T) []T

func Map

func Map[I, O any](arr []I, fn func(in I, index int) O) []O

func MapE

func MapE[I, O any](arr []I, fn func(in I, index int) (O, error)) ([]O, error)

func Reduce

func Reduce[I, O any](arr []I, fn func(acc O, in I, index int) O, acc O) O

func ReduceE

func ReduceE[I, O any](arr []I, fn func(acc O, in I, index int) (O, error), acc O) (O, error)

func Zip added in v0.4.43

func Zip[T any](args ...[]T) [][]T

Zip joins multiple slices

For example, Zip([a, b, c], [d, e, f]) returns [[a, d], [b, e], [c, f]] Each slice must have the same length (or it's an UB or even panic)

func ZipFlat added in v0.4.43

func ZipFlat[T any](args ...[]T) []T

ZipFlat likes Zip, but returns a flat slice

Types

This section is empty.

Jump to

Keyboard shortcuts

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