slice

package
v0.0.6 Latest Latest
Warning

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

Go to latest
Published: Oct 19, 2023 License: BSD-3-Clause Imports: 1 Imported by: 4

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FilterFn

func FilterFn[T any](fn func(T) bool, in ...T) []T

func FilterType

func FilterType[T any](in ...any) []T

FilterType returns a subset that matches the type.

func Find

func Find[T any](in ...any) (T, bool)

Find returns the first of type found. or false if not found.

func FindFn

func FindFn[T any](fn func(T) bool, in ...T) (T, bool)

func First

func First[T any](in ...T) (T, bool)

First returns the first element in a slice.

func FromMap

func FromMap[K comparable, V any](m map[K]V) (keys []K, values []V)

func FromMapKeys

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

func FromMapValues

func FromMapValues[K comparable, V any](m map[K]V, keys []K) (values []V)

func Map

func Map[T, U any](f func(int, T) U) func(...T) []U

Map applys func to each element s and returns results as slice.

func Reduce

func Reduce[T, R any](r R, fn func(T, R, int) R) func(...T) R

func ToMap

func ToMap[K comparable, V any](keys []K, values []V) (m map[K]V)

Types

type Pair

type Pair[K comparable, V any] struct {
	Key   K
	Value V
}

func Align

func Align[T any](k []T, v []T, less func(T, T) bool) []Pair[*T, *T]

func Zip

func Zip[K comparable, V any](k []K, v []V) []Pair[K, V]

Jump to

Keyboard shortcuts

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