slices

package
v0.0.0-...-bcfc501 Latest Latest
Warning

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

Go to latest
Published: Mar 24, 2025 License: MIT Imports: 2 Imported by: 0

Documentation

Overview

Package slices provides slice-related utilities.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Filter

func Filter[T any, P ~func(T) bool](x []T, pred P) []T

Filter returns a copy of x with any elements for which pred returns true.

func HasPrefix

func HasPrefix[T comparable](x []T, prefix []T) bool

HasPrefix evaluates if x contains prefix as its first len(prefix) elements.

func Iter

func Iter[T ~[]V, V any](s T) iter.Seq[V]

Iter returns an [iter.Seq[V]] that ranges over s.

func Iter2

func Iter2[T ~[]V, V any](s T) iter.Seq2[int, V]

Iter2 returns an [iter.Seq[int, V]] that ranges over s.

func Transform

func Transform[From any, To any, P ~func(From) To](x []From, mapper P) []To

Transform returns a copy of x with all elements' values passed through the given mapping function.

Types

This section is empty.

Jump to

Keyboard shortcuts

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