Documentation
¶
Index ¶
- 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 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 Pipe2[T1, T2, T3 any](tup T1, f1 func(T1) T2, f2 func(T2) T3) T3
- func Pipe3[T1, T2, T3, T4 any](initial T1, f1 func(T1) T2, f2 func(T2) T3, f3 func(T3) T4) T4
- func Pipe4[T1, T2, T3, T4, T5 any](initial T1, f1 func(T1) T2, f2 func(T2) T3, f3 func(T3) T4, f4 func(T4) T5) T5
- func RemoveStringItems(slice []string, items ...string) []string
- 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 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 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 Pipe2 ¶
func Pipe2[T1, T2, T3 any](tup T1, f1 func(T1) T2, f2 func(T2) T3) T3
Pipe2 creates a functional pipeline by taking an initial value and applying two functions in succession. The output of the first function becomes the input to the second function. The final return value is the result of the last function application.
func Pipe3 ¶
func Pipe3[T1, T2, T3, T4 any]( initial T1, f1 func(T1) T2, f2 func(T2) T3, f3 func(T3) T4, ) T4
Pipe3 creates a functional pipeline by taking an initial value and applying three functions in succession. The output of each function becomes the input to the next function. The final return value is the result of the last function application.
func Pipe4 ¶
func Pipe4[T1, T2, T3, T4, T5 any]( initial T1, f1 func(T1) T2, f2 func(T2) T3, f3 func(T3) T4, f4 func(T4) T5, ) T5
Pipe4 creates a functional pipeline by taking an initial value and applying four functions in succession. The output of each function becomes the input to the next function. The final return value is the result of the last function application.
func RemoveStringItems ¶
RemoveStringItems removes elements from a that are present in items.
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.