slices

package module
v0.0.0-...-d96704c Latest Latest
Warning

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

Go to latest
Published: Jan 19, 2024 License: MIT Imports: 1 Imported by: 4

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Filter

func Filter[I ~[]E, E any](i I, f func(E) bool) (o I)

Filter returns a new slice containing all of the elements for which the provided function returned true, in order.

func Flatten

func Flatten[O []E, I ~[]O, E any](i I) (o O)

Flatten returns a new slice containing all of the elements, in order of the provided slice of slices.

func Last

func Last[I ~[]E, E any](i I) (e E)

Last returns the last element of the provided slice, or the zero value of that type if the slice is empty.

func Reduce

func Reduce[O any, I ~[]E, E any](i I, f func(O, E) O) (o O)

Reduce runs the provided function once for each element, in order, accumulating the result in `O`.

func ToMap

func ToMap[O map[K]V, I ~[]E, K comparable, V, E any](i I, f func(E) (K, V)) (o O)

ToMap uses the provided function to transform the elements of the provided slice into a map.

func Transform

func Transform[O []E2, I ~[]E1, E1, E2 any](i I, f func(E1) E2) (o O)

Transform uses the provided function to transform the elements of the provided slice into a new slice. The returned slice does not have a stable order.

func Zip

func Zip[O []I, I ~[]E, E any](i ...I) O

Zip combines the element at each index from each slice into a new slice of the input type. These slices are returned in order, from 0 to the length of the shortest input slice.

Types

This section is empty.

Jump to

Keyboard shortcuts

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