slicesx

package
v1.46.1 Latest Latest
Warning

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

Go to latest
Published: Jul 26, 2023 License: BSD-3-Clause Imports: 1 Imported by: 9

Documentation

Overview

Package slicesx contains some helpful generic slice functions.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Interleave

func Interleave[S ~[]T, T any](a, b S) S

Interleave combines two slices of the form [a, b, c] and [x, y, z] into a slice with elements interleaved; i.e. [a, x, b, y, c, z].

func Partition added in v1.44.0

func Partition[S ~[]T, T any](s S, cb func(T) bool) (trues, falses S)

Partition returns two slices, the first containing the elements of the input slice for which the callback evaluates to true, the second containing the rest.

This function does not mutate s.

func Shuffle

func Shuffle[S ~[]T, T any](s S)

Shuffle randomly shuffles a slice in-place, similar to rand.Shuffle.

Types

This section is empty.

Jump to

Keyboard shortcuts

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