xslices

package
v0.13.0 Latest Latest
Warning

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

Go to latest
Published: Jul 12, 2024 License: MIT Imports: 1 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AppendChunkBy added in v0.13.0

func AppendChunkBy[E any, S ~[]E, R comparable](to []S, s S, val func(E) R) []S

AppendChunkBy is the same as ChunkBy but it appends the results to to instead of allocating its own slice.

func ChunkBy added in v0.13.0

func ChunkBy[E any, S ~[]E, R comparable](s S, val func(E) R) []S

ChunkBy returns a slice of subsequent subsclies of s such that each subslice is a continuous run of elements for which val(element) returns the same value. In other words, a new chunk starts each time that the return value of val(element) changes.

If len(s) == 0, the length of the returned slice will also be 0.

func Filter added in v0.7.3

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

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

func Partition

func Partition[E any, S ~[]E](s S, pred func(E) bool) (t, f S)

Partition returns two slices, t and f. t contains all elements of s for which pred() returns true, and f contains all elements for which pred() returns false.

Types

This section is empty.

Jump to

Keyboard shortcuts

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