package sliceutil

import "go.abhg.dev/doc2go/internal/sliceutil"

Package sliceutil contains generic functions for working with slices. Use it to augment the std "slices" package.

Index

Functions

func RemoveCommonPrefix

func RemoveCommonPrefix[T comparable](a, b []T) (newA, newB []T)

RemoveCommonPrefix removes the shared prefix from the two provided slices, returning what remains for each slice as the result.

func RemoveFunc

func RemoveFunc[T any](items []T, skip func(T) bool) []T

RemoveFunc removes items matching the given function from the provided slice.

The original slice must not be used after this.

func Transform

func Transform[From, To any](from []From, f func(From) To) []To

Transform builds a slice by applying the provided function to all elements in the given slice.