slice

package
v0.0.0-...-4a63a45 Latest Latest
Warning

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

Go to latest
Published: Sep 12, 2024 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Collect

func Collect[T, U any](seq2 iter.Seq2[T, U]) ([]T, []U)

func Concat

func Concat[T any](slice1, slice2 []T) []T

func Filter

func Filter[T any](slice []T, p func(T) bool) []T

func FlatMap

func FlatMap[T, U any](slice []T, f func(T) []U) []U

func Flatten

func Flatten[T any](slices [][]T) []T

func FoldLeft

func FoldLeft[T any, U any](slice []T, f func(u U, t T) U, u U) U

func FoldRight

func FoldRight[T any, U any](slice []T, f func(t T, u U) U, u U) U

func Join

func Join[T ~string](strings []T, sep T) T

func JoinErrs

func JoinErrs(errs []error) error

func Map

func Map[T any, U any](slice []T, f func(T) U) []U

func Partition

func Partition[T any](slice []T, size int) [][]T

func Reduce

func Reduce[T any](slice []T, op func(t1, t2 T) T, initial T) T

func Sum

func Sum[M Monad](numbers []M) M

func UnZip

func UnZip[T, U any](slice []Pair[T, U]) ([]T, []U)

Types

type Monad

type Monad interface {
	constraints.Integer | constraints.Float | constraints.Complex | ~string
}

Monad represents any type that can use the `+` operator and whose zero value is the identity element the `+` operator

type Pair

type Pair[T1, T2 any] struct {
	// contains filtered or unexported fields
}

func Zip

func Zip[T, U any](slice1 []T, slice2 []U) []Pair[T, U]

Jump to

Keyboard shortcuts

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