slice

package
v0.1.11 Latest Latest
Warning

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

Go to latest
Published: Jul 10, 2023 License: Apache-2.0 Imports: 0 Imported by: 1

README

slice

Go Report Card Documentation license

Simplifies slice operations in Go, with generics!

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Contains

func Contains[T comparable](slice []T, e T) bool

Contains returns true if a slice contains an element

func Map added in v0.1.2

func Map[T any, K comparable, V any](slice []T, fn func(T) (K, V)) map[K]V

Map takes a slice of a given type and a function to extract a map key and value from slice elements, returns a new map with those key-value pairs. Note that if multiple elements in the slice return the same key, the element that appears last in the slice will be the (only) element that maps to the key.

func Transform

func Transform[T any, V any](slice []T, fn func(T) V) []V

Transform takes a slice of a given type, and a function to perform on each element to transform it into a different type

Types

This section is empty.

Jump to

Keyboard shortcuts

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