Documentation
¶
Index ¶
- func All[Element any](elements []Element, fun func(Element) bool) bool
- func Any[Element any](elements []Element, fun func(Element) bool) bool
- func Count[Element any](elements []Element) int
- func CountBy[Element any](elements []Element, fun func(Element) bool) int
- func Each[Element any](elements []Element, fun func(Element))
- func Filter[Element any](elements []Element, fun func(Element) bool) []Element
- func FlatMap[Element any](elements []Element, fun func(Element) []Element) []Element
- func Frequencies[Element comparable](elements []Element) map[Element]int
- func FrequenciesBy[Element any, Key comparable](elements []Element, fun func(Element) Key) map[Key]int
- func GroupBy[Element any, GroupBy comparable](elements []Element, fun func(Element) GroupBy) map[GroupBy][]Element
- func IsMember[Element comparable](elements []Element, member Element) bool
- func IsMemberBy[Element any, IsMemberBy comparable](elements []Element, member Element, fun func(Element) IsMemberBy) bool
- func Map[Element any, ReturnElement any](elements []Element, fun func(Element) ReturnElement) []ReturnElement
- func Max[Element constraints.Ordered](elements []Element) Element
- func MaxBy[Element any, CompareBy constraints.Ordered](elements []Element, fun func(Element) CompareBy) Element
- func Min[Element constraints.Ordered](elements []Element) Element
- func MinBy[Element any, CompareBy constraints.Ordered](elements []Element, fun func(Element) CompareBy) Element
- func MinMax[Element constraints.Ordered](elements []Element) (Element, Element)
- func MinMaxBy[Element any, CompareBy constraints.Ordered](elements []Element, fun func(Element) CompareBy) (Element, Element)
- func Product[Element Number](elements []Element) Element
- func ProductBy[Element any, Product Number](elements []Element, fun func(Element) Product) Product
- func Random[Element any](elements []Element, seed ...int64) Element
- func Reduce[Element any, Accumulator any](elements []Element, fun func(Element, Accumulator) Accumulator, ...) Accumulator
- func ReduceWhile[Element any, Accumulator any](elements []Element, fun func(Element, Accumulator) (Reduction, Accumulator), ...) Accumulator
- func Reject[Element any](elements []Element, fun func(Element) bool) []Element
- func Reverse[Element comparable](elements []Element) []Element
- func Shuffle[Element any](elements []Element, seed ...int64) []Element
- func Sort[Element constraints.Ordered](elements []Element, order Order) []Element
- func SortBy[Element any, SortBy constraints.Ordered](elements []Element, fun func(Element) SortBy, order Order) []Element
- func SplitWhile[Element any](elements []Element, fun func(Element) bool) ([]Element, []Element)
- func SplitWith[Element any](elements []Element, fun func(Element) bool) ([]Element, []Element)
- func Sum[Element Number](elements []Element) Element
- func SumBy[Element any, SumBy Number](elements []Element, fun func(Element) SumBy) SumBy
- func Take[Element any](elements []Element, amount uint) []Element
- func TakeWhile[Element any](elements []Element, fun func(Element) bool) []Element
- func Uniq[Element comparable](elements []Element) []Element
- func UniqBy[Element any, UniqBy comparable](elements []Element, fun func(Element) UniqBy) []Element
- type Number
- type Order
- type Reduction
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Each ¶
func Each[Element any](elements []Element, fun func(Element))
Each invokes fun on each element in the slice.
func FlatMap ¶
func FlatMap[Element any](elements []Element, fun func(Element) []Element) []Element
FlatMap maps the given fun over slice and flattens the result.
func Frequencies ¶
func Frequencies[Element comparable](elements []Element) map[Element]int
Frequencies returns a map with keys as unique elements and values as the count of every element.
func FrequenciesBy ¶
func FrequenciesBy[Element any, Key comparable](elements []Element, fun func(Element) Key) map[Key]int
FrequenciesBy returns a map with keys as unique elements given by key_fun and values as the count of every element.
func GroupBy ¶
func GroupBy[Element any, GroupBy comparable](elements []Element, fun func(Element) GroupBy) map[GroupBy][]Element
GroupBy splits the slice into groups based on key_fun.
func IsMember ¶
func IsMember[Element comparable](elements []Element, member Element) bool
IsMember checks if element exists in the slice.
func IsMemberBy ¶
func IsMemberBy[Element any, IsMemberBy comparable](elements []Element, member Element, fun func(Element) IsMemberBy) bool
IsMemberBy checks if element exists in the slice according to fun.
func Map ¶
func Map[Element any, ReturnElement any](elements []Element, fun func(Element) ReturnElement) []ReturnElement
Map invokes fun on each element in the slice.
func Max ¶
func Max[Element constraints.Ordered](elements []Element) Element
Max returns the maximum element in the slice.
func MaxBy ¶
func MaxBy[Element any, CompareBy constraints.Ordered](elements []Element, fun func(Element) CompareBy) Element
MaxBy returns the maximum element in the slice according to fun.
func Min ¶
func Min[Element constraints.Ordered](elements []Element) Element
Min returns the minimum element in the slice.
func MinBy ¶
func MinBy[Element any, CompareBy constraints.Ordered](elements []Element, fun func(Element) CompareBy) Element
MinBy returns the minimum element in the slice according to fun.
func MinMax ¶
func MinMax[Element constraints.Ordered](elements []Element) (Element, Element)
MinMax returns the minimum and maximum element in the slice.
func MinMaxBy ¶
func MinMaxBy[Element any, CompareBy constraints.Ordered](elements []Element, fun func(Element) CompareBy) (Element, Element)
MinMaxBy returns the minimum and maximum element in the slice according to fun.
func Product ¶
func Product[Element Number](elements []Element) Element
Product returns the product of all elements.
func Reduce ¶
func Reduce[Element any, Accumulator any](elements []Element, fun func(Element, Accumulator) Accumulator, accumulator Accumulator) Accumulator
Reduce invokes fun on each element in the slice with the accumulator.
func ReduceWhile ¶
func ReduceWhile[Element any, Accumulator any](elements []Element, fun func(Element, Accumulator) (Reduction, Accumulator), accumulator Accumulator) Accumulator
ReduceWhile invokes fun on each element in the slice with the accumulator until Halt is returned.
func Reverse ¶
func Reverse[Element comparable](elements []Element) []Element
Reverse returns a slice of elements in reverse order.
func Sort ¶
func Sort[Element constraints.Ordered](elements []Element, order Order) []Element
Sort returns a slice sorted according to fun.
func SortBy ¶
func SortBy[Element any, SortBy constraints.Ordered](elements []Element, fun func(Element) SortBy, order Order) []Element
SortBy returns a slice sorted according to fun.
func SplitWhile ¶
SplitWhile splits the slice in two at the position of the element for which fun returns a false for the first time.
func Sum ¶
func Sum[Element Number](elements []Element) Element
Sum returns the sum of all elements.
func TakeWhile ¶
TakeWhile takes the elements from the beginning of the slice while fun returns a truthy value.
func Uniq ¶
func Uniq[Element comparable](elements []Element) []Element
Uniq iterates over the slice, removing all duplicated elements.
func UniqBy ¶
func UniqBy[Element any, UniqBy comparable](elements []Element, fun func(Element) UniqBy) []Element
UniqBy iterates over the slice, removing all duplicated elements according to fun.
Types ¶
type Number ¶
type Number interface {
constraints.Integer | constraints.Float
}