slice

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Jul 7, 2023 License: MIT Imports: 0 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Filter

func Filter[S ~[]T, T any](s S, fn func(T) bool) S

Filter [Filter[T]] is a function that takes a slice of type T and a function that takes a value of type T and returns a boolean. It returns a new slice containing only the elements of the input slice for which the function returns true.

func Map

func Map[In, Out any](s []In, fn func(In) Out) []Out

Map applies a given function to each element of a slice[[]], returning a new slice[] with the results. The function takes an element of the input slice as its argument and returns the corresponding element of the output slice[].

func NoZero

func NoZero[S ~[]T, T comparable](s S) S

NoZero removes all zero values from a given slice [S] of comparable type [T]. It returns a new slice with only the non-zero values.

func Unique

func Unique[S ~[]T, T comparable](s S) S

Unique returns a new slice with only the unique elements of the input slice. The function accepts a slice of type [S ~[]T, T comparable](S), where T is a comparable type. The resulting slice has the same underlying type as the 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