slice

package
v0.17.0 Latest Latest
Warning

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

Go to latest
Published: Apr 8, 2025 License: MIT Imports: 1 Imported by: 0

Documentation

Overview

Deprecated: slice is deprecated - use github.com/neticdk/go-stdlib/xslices

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Filter

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

Filter returns a new slice containing only the elements of the slice that satisfy the predicate. Deprecated: Filter is deprecated - use github.com/neticdk/go-stdlib/xslices.Filter

func FindFunc added in v0.9.3

func FindFunc[T any](data []T, f func(T) bool) (T, bool)

FindFunc returns the first element in the slice that satisfies the predicate.

It returns the default value for the type and false if no element satisfies the predicate. Deprecated: FindFunc is deprecated - use github.com/neticdk/go-stdlib/xslices.FindFunc

func FindIFunc added in v0.9.3

func FindIFunc[T any](data []T, f func(T) bool) (int, bool)

FindIFunc returns the index of the first element in the slice that satisfies the predicate.

It returns -1 and false if no element satisfies the predicate Deprecated: FindIFunc is deprecated - use github.com/neticdk/go-stdlib/xslices.FindIFunc

func Fold added in v0.12.0

func Fold[T, S any](acc T, data []S, f func(T, S) T) T

Fold applies a function to each element of the slice. storing the result in an accumulator. It applies the function from left to right. Deprecated: Fold is deprecated - use github.com/neticdk/go-stdlib/xslices.Fold

func FoldR added in v0.12.0

func FoldR[T, S any](acc T, data []S, f func(T, S) T) T

FoldR applies a function to each element of the slice. storing the result in an accumulator. It applies the function from right to left. Deprecated: FoldR is deprecated - use github.com/neticdk/go-stdlib/xslices.FoldR

func Intersect

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

Intersect returns the intersection of two comparable slices. Deprecated: Intersect is deprecated - use github.com/neticdk/go-stdlib/xslices.Intersect

func Map

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

Map applies a function to each element of a slice and returns a new slice with the results. Deprecated: Map is deprecated - use github.com/neticdk/go-stdlib/xslices.Map

func Unfold added in v0.12.0

func Unfold[T any](acc T, f func(T) T, p func(T) bool, opts ...xslices.UnfoldOption) []T

Unfold generates a slice by repeatedly applying a function to an accumulator. It includes the accumulator in the result as the first value. If the predicate is always false, it returns nil. It stops when the predicate returns false. Deprecated: Unfold is deprecated - use github.com/neticdk/go-stdlib/xslices.Unfold

func UnfoldI added in v0.12.0

func UnfoldI[T any](acc T, f func(T) T, n int, opts ...xslices.UnfoldOption) []T

UnfoldI generates a slice by repeatedly applying a function to an accumulator. It includes the accumulator in the result as the first value. The length of the result is equal to i + 1. If i is negative, it returns nil. It stops after i iterations. Deprecated: UnfoldI is deprecated - use github.com/neticdk/go-stdlib/xslices.UnfoldI

Types

This section is empty.

Jump to

Keyboard shortcuts

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