Documentation ¶
Overview ¶
Package slices contains functions for working with slices.
Index ¶
- func Contains[S ~[]E, E comparable](s S, e E) bool
- func Filter[S ~[]E, E any](s S, f func(E) bool) S
- func Map[S ~[]E, E, T any](s S, f func(E) T) []T
- func Remove[S ~[]E, E comparable](s S, e E) S
- func Reverse[S ~[]E, E comparable](s S)
- func Unique[S ~[]E, E comparable](s S) S
- func UniqueBy[S ~[]E, E any, V comparable](s S, by func(E) V) S
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Contains ¶
func Contains[S ~[]E, E comparable](s S, e E) bool
Contains returns true if e is in s.
func Filter ¶
Filter returns a new slice containing only those elements for which f(element) is true.
func Map ¶ added in v0.25.0
func Map[S ~[]E, E, T any](s S, f func(E) T) []T
Map constructs a new slice containing the elements obtained by invoking the function f on each element of s.
func Reverse ¶ added in v0.22.2
func Reverse[S ~[]E, E comparable](s S)
Reverse reverses a slice's order.
func UniqueBy ¶ added in v0.22.2
func UniqueBy[S ~[]E, E any, V comparable](s S, by func(E) V) S
UniqueBy returns the unique elements of s using a function to map elements.
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.