Documentation ¶
Index ¶
- func AllFunc[S ~[]T, T any](s S, predicate func(val T) bool) bool
- func AnyFunc[S ~[]T, T any](s S, predicate func(val T) bool) bool
- func Apply[S ~[]E, E any](s S, f func(E))
- func Concatenate[S ~[]E, E any](s ...S) S
- func Filter[S ~[]E, E any](s S, predicate func(e E) bool) S
- func Flatten[S ~[]E, E any](s []S) S
- func GroupByFunc[S ~[]E, E any, K comparable](s S, keyFunc func(E) K) map[K]S
- func GroupByFuncUnique[S ~[]E, E any, K comparable](s S, keyFunc func(E) K) map[K]E
- func Map[S ~[]E, E any, V any](s S, f func(E) V) []V
- func MapAndGroupByFuncs[S ~[]E, E any, K comparable, V any](s S, keyFunc func(E) K, mapFunc func(E) V) map[K][]V
- func Partition[S ~[]E, E any](s S, n int) []S
- func PartitionToMaxLen[S ~[]E, E any](s S, maxLen int) []S
- func Pop[S ~[]E, E any](s *S) E
- func Repeat[T any](n int, vs ...T) []T
- func Shuffle[S ~[]E, E any](s ...S)
- func Subtract[T comparable](list []T, toRemove []T) []T
- func Unique[S ~[]E, E comparable](s S) S
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AllFunc ¶ added in v0.9.8
AllFunc returns true if predicate(v) returns true for all values v in s.
func AnyFunc ¶ added in v0.4.5
AnyFunc returns true if predicate(v) returns true for any value v in s.
func Apply ¶ added in v0.9.8
func Apply[S ~[]E, E any](s S, f func(E))
Apply applies the given function to all elements of the input slice
func Concatenate ¶ added in v0.3.63
func Concatenate[S ~[]E, E any](s ...S) S
Concatenate returns a single slice created by concatenating the input slices.
func Flatten ¶ added in v0.3.50
func Flatten[S ~[]E, E any](s []S) S
Flatten merges a slice of slices into a single slice.
func GroupByFunc ¶ added in v0.3.50
func GroupByFunc[S ~[]E, E any, K comparable](s S, keyFunc func(E) K) map[K]S
GroupByFunc groups the elements e_1, ..., e_n of s into separate slices by keyFunc(e).
func GroupByFuncUnique ¶ added in v0.3.81
func GroupByFuncUnique[S ~[]E, E any, K comparable](s S, keyFunc func(E) K) map[K]E
GroupByFuncUnique returns a map keyFunc(e) to e for each element e in s.
func Map ¶
Map Returns a slice consisting of the results of applying the given function to the elements of the input slice
func MapAndGroupByFuncs ¶ added in v0.3.50
func MapAndGroupByFuncs[S ~[]E, E any, K comparable, V any](s S, keyFunc func(E) K, mapFunc func(E) V) map[K][]V
MapAndGroupByFuncs groups the elements e_1, ..., e_n of s into separate slices by keyFunc(e) and then maps those resulting elements by mapFunc(e).
func Partition ¶ added in v0.3.50
Partition partitions the elements of s into n non-overlapping slices, such that some slices have len(s)/n+1 items and some len(s)/n items. Ordering is preserved, such that Flatten(Partition(s)) is equal to s.
func PartitionToMaxLen ¶ added in v0.3.50
PartitionToMaxLen partitions the elements of s into non-overlapping slices, such that each such slice contains at most maxLen elements.
func Pop ¶ added in v0.3.81
func Pop[S ~[]E, E any](s *S) E
Pop removes the last item from s and returns it. Calling pop on an empty slice causes a panic.
func Repeat ¶ added in v0.3.90
Repeat returns a slice []T of length n*len(vs) consisting of n copies of vs.
func Subtract ¶ added in v0.3.50
func Subtract[T comparable](list []T, toRemove []T) []T
func Unique ¶ added in v0.3.63
func Unique[S ~[]E, E comparable](s S) S
Unique returns a copy of s with duplicate elements removed, keeping only the first occurrence.
Types ¶
This section is empty.