generic

package
v0.0.0-...-202847b Latest Latest
Warning

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

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

Documentation

Overview

Package generic contains all generic functions. Please use https://github.com/samber/lo

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Contains

func Contains[T comparable](s []T, v T) bool

func Filter

func Filter[T any](s []T, f func(T) bool) []T

Filter filters slice s with predicate f and re-uses the backing array of "s".

func FilterNew

func FilterNew[T any](s []T, f func(T) bool) []T

FilterNew filters slice s with predicate f. Returns a new slice, leaving s untouched. Might return a nil slice.

func Intersection

func Intersection[A comparable](a []A, b []A) (intersection []A)

Intersection returns a list of common elements present in both arrays. The elements in the output can be in any order.

func Map

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

Map maps function f to each element of slice "s". It changes slice "s".

func MapNew

func MapNew[T any](s []T, f func(T) T) []T

MapNew maps function f to each slice element and returns a new slice, leaving input slice "s" untouched.

func Reduce

func Reduce[T any](s []T, init T, f func(T, T) T) T

func RemoveEmpty

func RemoveEmpty[T comparable](slIN []T) []T

func Reverse

func Reverse[T any](s []T) []T

func ToAnySlice

func ToAnySlice[T any](slice []T) []any

func ToStringSlice

func ToStringSlice[T ~string](strs ...T) []string

func Window

func Window[S any](elements []S, size int) [][]S

Types

This section is empty.

Jump to

Keyboard shortcuts

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