slicex

package
v0.0.0-...-02246d9 Latest Latest
Warning

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

Go to latest
Published: Nov 16, 2023 License: BSD-3-Clause Imports: 2 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Chunk

func Chunk[T comparable](items []T, size int) [][]T

Chunk chunks a slice by size

func Diff

func Diff[T comparable](values ...[]T) []T

Diff return a slice in ss[0] and not in ss[1:]

func Filter

func Filter[T comparable](values []T, f func(v T) bool) []T

Filter return matched f function condition value

Example:

Filter([]int{0, 1, 2, 3}, func(v int) bool {
	return v > 0
})
// Output: [1, 2, 3]

func IntSliceDiff

func IntSliceDiff(ss ...[]int) []int

func IntSliceEqual

func IntSliceEqual(a, b []int) bool

IntSliceEqual Check a, b is equal

func IntSliceReverse

func IntSliceReverse(ss []int) []int

func IntToInterface

func IntToInterface(values []int) []interface{}

IntToInterface Change int slice to interface slice

func Map

func Map[T comparable](values []T, f func(v T) T) []T

Map values all value execute f function, and return a new slice

Example

Map([]string{"A", "B", "C"}, func(v string) string {
	return strings.ToLower(v)
})
// Output: ["a", "b", "c"]

func StringSliceDiff

func StringSliceDiff(ss ...[]string) []string

func StringSliceEqual

func StringSliceEqual(a, b []string, caseSensitive, ignoreEmpty, trim bool) bool

StringSliceEqual Check a, b is equal

func StringSliceReverse

func StringSliceReverse(ss []string) []string

func StringToInterface

func StringToInterface(values []string) []interface{}

StringToInterface Change string slice to interface slice

func ToInterface

func ToInterface[T gox.Number | ~string](values []T) []interface{}

Types

This section is empty.

Jump to

Keyboard shortcuts

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