xslices

package
v1.4.4 Latest Latest
Warning

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

Go to latest
Published: Nov 16, 2026 License: MIT Imports: 4 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Average

func Average[T generic.Numeric](xs []T, precision ...int) float64

Average 求数字切片的平均值, 可选指定保留小数位数

func Chunk

func Chunk[T any, S ~[]T](ss S, size int) []S

Chunk 按指定 size 对元素切片分组

func Deduplication

func Deduplication[E comparable](s []E) []E

Deduplication removes repeatable elements from s.

func Filter

func Filter[E any, S ~[]E](s S, pred func(E) bool) S

Filter removes any elements from s for which pred(element) is false.

func Max

func Max[T cmp.Ordered](xs ...T) (y T)

func Merge

func Merge[E any](s []E, ss ...[]E) []E

Merge 浅拷贝合并多个切片, 不影响原切片. 没有后续切片时返回原切片, 保留 nil 与空切片的区别; 首切片为空仍合并后续输入.

func Min

func Min[T cmp.Ordered](xs ...T) (y T)

func ToString

func ToString[T any](xs []T, sep string) string

ToString 将切片拼接成字符串

Types

This section is empty.

Jump to

Keyboard shortcuts

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