Documentation
¶
Index ¶
- func AllExist[T comparable](superset, subset []T) bool
- func CurriedFilter[T any](predicate func(T) bool) func([]T) []T
- func CurriedMap[T1, T2 any](fnc func(T1) T2) func([]T1) []T2
- func CurriedPartition[T any](predicate func(T) bool) func([]T) ([]T, []T)
- func CurriedPartitionTuple2[T any](predicate func(T) bool) func([]T) Tuple2[[]T, []T]
- func CurriedTFold[A, B, R any](folder func(Tuple2[A, B]) R) func(Tuple2[A, B]) R
- func Filter[T any](slice []T, predicate func(T) bool) []T
- func Find[T any](slice []T, predicate func(T) bool) (*T, bool)
- func Include[T cmp.Ordered](slice []T, element T) bool
- func IsEmpty[T any](slice []T) bool
- func Map[T1, T2 any](slc []T1, fnc func(T1) T2) []T2
- func MapSeq[T1, T2 any](seq iter.Seq[T1], fn func(T1) T2) iter.Seq[T2]
- func Partition[T any](slice []T, predicate func(T) bool) ([]T, []T)
- func RemoveStringItems(slice []string, items ...string) []string
- func Sorted[T cmp.Ordered](slice []T) []T
- func TFold[A, B, R any](tup Tuple2[A, B], folder func(Tuple2[A, B]) R) R
- type Tuple2
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AllExist ¶
func AllExist[T comparable](superset, subset []T) bool
AllExist checks if all elements of a subset slice are present in a superset slice.
func CurriedFilter ¶
CurriedFilter returns a function that, when given a slice, filters it based on the provided predicate. This is a curried version of the Filter function.
func CurriedMap ¶
func CurriedMap[T1, T2 any](fnc func(T1) T2) func([]T1) []T2
CurriedMap returns a function that, when given a slice, applies the provided function to each element of the slice. This is a curried version of the Map function.
func CurriedPartition ¶
CurriedPartition returns a function that, when given a slice, partitions it based on the provided predicate. This is a curried version of the Partition function.
func CurriedPartitionTuple2 ¶
CurriedPartitionTuple2 returns a function that, when given a slice, partitions it based on the provided predicate and returns the result as a Tuple2. This is a curried version of the PartitionTuple2 function.
func CurriedTFold ¶
CurriedFold returns a function that applies the folder function to a Tuple2, returning a result of type R. This is a curried version of Fold.
func Find ¶
Find searches for an element in a slice that satisfies the predicate. It returns a pointer to the first element found and true, or nil and false if no element is found.
func Include ¶
Include determines whether the given element is present in the slice. The slice is sorted before searching.
func IsEmpty ¶
IsEmpty checks if a slice is empty (has zero elements). Returns true if the slice is nil or has no elements, false otherwise.
func Map ¶
func Map[T1, T2 any](slc []T1, fnc func(T1) T2) []T2
Map returns the slice obtained after applying the given function over every element in the given slice.
func MapSeq ¶
MapSeq transforms an iter.Seq to another iter.Seq by applying the given function to each element in the sequence.
func Partition ¶
Partition splits a slice into two slices based on a predicate function. The first returned slice contains all elements for which the predicate returns true, and the second contains all elements for which the predicate returns false.
func RemoveStringItems ¶
RemoveStringItems removes elements from a that are present in items.
func Sorted ¶
Sorted returns a new slice containing the elements of the input slice sorted in ascending order. The original slice is not modified.
Types ¶
type Tuple2 ¶
type Tuple2[T1, T2 any] struct { First T1 Second T2 }
Tuple2 represents a pair of values with independent types. It's useful for functions that need to return two values of different types.
func PartitionTuple2 ¶
PartitionTuple2 splits a slice into two parts based on a predicate function and returns them as a Tuple2. The First field contains all elements for which the predicate returns true, and the Second field contains all elements for which the predicate returns false.
func SliceToTuple2 ¶
SliceToTuple2 converts the first two elements of a slice to a Tuple2. If the slice has fewer than two elements, it uses zero values for the missing elements.