slices2

package
v0.0.0-...-cb92b4e Latest Latest
Warning

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

Go to latest
Published: Sep 24, 2023 License: MPL-2.0 Imports: 1 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DedupSorted

func DedupSorted[T comparable, S ~[]T](xs S) S

DedupSorted removes duplicate items according to eq It doesn't actually matter how the items are sorted as long as items which could be the same are adjacent.

func DedupSortedFunc

func DedupSortedFunc[T any, S ~[]T](xs S, eq func(a, b T) bool) S

DedupSortedFunc removes duplicate items according to eq It doesn't actually matter how the items are sorted as long as items which could be the same are adjacent. Note that the last arg `eq` is a function that returns true for equality, not for less-than.

func Filter

func Filter[T any, S ~[]T](xs S, fn func(T) bool) S

Filter modifies xs in place to remove all elements x for which fn(x) is false.

func FoldLeft

func FoldLeft[X, Acc any, S ~[]X](xs S, init Acc, fn func(Acc, X) Acc) Acc

FoldLeft implements foldl, as described here https://en.wikipedia.org/wiki/Fold_(higher-order_function)

func FoldRight

func FoldRight[X, Acc any, S ~[]X](xs S, init Acc, fn func(Acc, X) Acc) Acc

FoldRight implements foldr, as described here https://en.wikipedia.org/wiki/Fold_(higher-order_function)

func Map

func Map[A, B any, SA ~[]A](as SA, fn func(A) B) []B

Map returns a new slice with fn applied to all the elements.

func Merge

func Merge[T cmp.Ordered, S ~[]T](dst S, left, right S) int

func MergeFunc

func MergeFunc[T any, S ~[]T](dst S, left, right S, cmp func(a, b T) int) (n int)

Types

This section is empty.

Jump to

Keyboard shortcuts

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