slices

package
v0.29.1 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Clean

func Clean[T comparable](slice []T) []T

Clean removes all zero values from a slice.

func Difference added in v0.28.0

func Difference[T comparable](a, b []T) []T

Difference returns the difference between two slices a and b, it should contain all the elements that are in a but not in b.

func Disjoint

func Disjoint[T comparable](a, b []T) bool

Disjoint returns true if the two slices have no elements in common.

func DisjointTransform

func DisjointTransform[T comparable](a, b []T, transformA, transformB TransformFunc[T]) bool

DisjointTransform returns true if the two slices have no elements in common, it takes two transform functions that are applied to the elements of each slice before comparing them.

func Intersection

func Intersection[T comparable](a, b []T) []T

func Map added in v0.28.0

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

Map returns a new slice containing the results of applying the function f to each element of the original slice.

func Uniq

func Uniq[T comparable](s []T) []T

Types

type TransformFunc

type TransformFunc[T comparable] func(T) T

Jump to

Keyboard shortcuts

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