helpers

package
v0.0.0-...-610fc40 Latest Latest
Warning

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

Go to latest
Published: Jan 20, 2023 License: Unlicense Imports: 1 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Last

func Last[T any](collection []T) (init []T, last T)

Last removes the Last element from collection and returns the resulting slice and the final element. The last of a single item is an empty slice and itself.

func Pop

func Pop[T any](collection []T) (head T, tail []T)

Pop removes and returns the first element of collection and the resulting slice. The head of a single item is itself and an empty slice.

func SliceEqual

func SliceEqual[V constraints.Ordered](first, second []V) bool

SliceEqual will attempt to test each slice element for equality in order.

func TakeN

func TakeN[T any](count int, from []T) (remaining []T, taken []T)

TakeN will remove count elements from the end of from and return slices of both the remaining elements and the taken elements. The taken elements retain the order of the original slice. Will return empty slices if the from slice is empty. Attempting to take a negative number of elements will result in returning the given slice unaltered and an empty taken slice. Taking more elements than that which exists in the given collection will result in an empty remaining slice and the given collection.

Types

This section is empty.

Jump to

Keyboard shortcuts

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