Documentation
¶
Index ¶
- func Abs[T constraints.Integer | constraints.Float](x T) T
- func All[T any](in []T, allFn func(T) bool) bool
- func Any[T any](in []T, anyFn func(T) bool) bool
- func Atoi(a string) int
- func Atoi64(a string) int64
- func Carve[T any](in []T, i, j int) []T
- func Chunk[T any](in []T, size int) [][]T
- func Combinations[T any](in []T) [][2]T
- func Concat[V any](seqs ...iter.Seq[V]) iter.Seq[V]
- func Cons[T any](in []T, offset int) [][2]T
- func Count[T any](in []T, countFn func(T) bool) int
- func Cycle[T any](s iter.Seq[T]) iter.Seq[T]
- func Each[T any](in []T, f func(T))
- func EachMap[T comparable, V any](in map[T]V, f func(T, V))
- func GCD(a, b int) int
- func IPow(base, exp int64) int64
- func Includes[T comparable](in []T, value T) bool
- func Intersection[T comparable](x ...[]T) []T
- func Join[T any](in []T, sep string) string
- func KeyWithMaxValue[T comparable, V constraints.Ordered](in map[T]V) T
- func KeyWithValue[T comparable, V comparable](in map[T]V, val V) T
- func LCM(nums []int) int
- func Map[T any, V any](in []T, f func(T) V) []V
- func MapM[T comparable, V any](in []T, f func(T) (T, V)) map[T]V
- func MapMap[T comparable, V any, X comparable, Y any](in map[T]V, f func(T, V) (X, Y)) map[X]Y
- func MapWithIndex[T any, V any](in []T, f func(int, T) V) []V
- func Max[T constraints.Ordered](in []T) T
- func MaxWithIndex[T constraints.Ordered](in []T) (int, T)
- func Min[T constraints.Ordered](in []T) T
- func MinMax[T constraints.Ordered](in []T) (T, T)
- func MinWithIndex[T constraints.Ordered](in []T) (int, T)
- func Partition[T any](in []T, partFn func(T) bool) ([]T, []T)
- func Permutations[T any](in []T) [][]T
- func Product[T constraints.Integer | constraints.Float](in []T) T
- func Reduce[T any, A any](in []T, initial A, reduceFn func(A, T) A) A
- func Reject[T any](in []T, f func(T) bool) []T
- func Repeat[T any](x T, i int) []T
- func Reverse[T any](in []T) []T
- func Select[T any](in []T, f func(i T) bool) []T
- func SelectMap[T comparable, V any](in map[T]V, f func(i T, j V) bool) map[T]V
- func Sign[T constraints.Integer | constraints.Float](x T) T
- func Sort[T constraints.Ordered](in []T) []T
- func SubSlice[T comparable](a, b []T) []T
- func Sum[T constraints.Integer | constraints.Float](in []T) T
- func Tally[T comparable](in []T) map[T]int
- func Union[T comparable](x []T, y []T) []T
- func Zip[T any](in ...[]T) [][]T
- type Point
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Abs ¶
func Abs[T constraints.Integer | constraints.Float](x T) T
func All ¶
All returns a bool indicating if all values in the input slice produce a true value when evaluated by allFn
func Any ¶
Any returns a bool indicating if any value in the input slice produce a true value when evaluated by anyFn
func Combinations ¶
func Combinations[T any](in []T) [][2]T
Combinations return a slice of tuples of all 2 value combinations of the input slice
func Cons ¶
Cons take an input slice and an offset and loops though the slice making a tuple of index and index+offset
func Count ¶
Count returns an int of the number if values in the input slice that return true when evaluated by countFn
func EachMap ¶
func EachMap[T comparable, V any](in map[T]V, f func(T, V))
func Includes ¶
func Includes[T comparable](in []T, value T) bool
Includes returns true if any value in the input slice matches value
func Intersection ¶
func Intersection[T comparable](x ...[]T) []T
func KeyWithMaxValue ¶
func KeyWithMaxValue[T comparable, V constraints.Ordered](in map[T]V) T
KeyWithMaxValue takes a map and returns the key in the map that is associated with the maximum value. As maps are read in random order if the maximum value is shared the returned k is not deterministic
func KeyWithValue ¶
func KeyWithValue[T comparable, V comparable](in map[T]V, val V) T
func Map ¶
Map takes an input slice and a mapping function and returns a slice of values as modified by f
func MapM ¶
func MapM[T comparable, V any](in []T, f func(T) (T, V)) map[T]V
func MapMap ¶
func MapMap[T comparable, V any, X comparable, Y any](in map[T]V, f func(T, V) (X, Y)) map[X]Y
func MapWithIndex ¶
func Max ¶
func Max[T constraints.Ordered](in []T) T
Max returns the maximum value in the input slice
func MaxWithIndex ¶
func MaxWithIndex[T constraints.Ordered](in []T) (int, T)
MaxWithIndex returns the index of, and the maximum value in the input slice
func Min ¶
func Min[T constraints.Ordered](in []T) T
Min returns the minimum value in the input slice
func MinMax ¶
func MinMax[T constraints.Ordered](in []T) (T, T)
MinMax returns two values, the minimum and maximum value in the input slice
func MinWithIndex ¶
func MinWithIndex[T constraints.Ordered](in []T) (int, T)
MinWithIndex returns the minimum value in the input slice
func Partition ¶
Partition takes an input slice and returns two slices using partFn to decide which it goes in, the first return value is the slice of values that return true when evaluated by partFn the second return is those that return false
func Permutations ¶
func Permutations[T any](in []T) [][]T
func Product ¶
func Product[T constraints.Integer | constraints.Float](in []T) T
Product returns the product of values in the input slice
func Reduce ¶
Reduce takes an input slice, and initial value and a reduce function it passes every value in the input slice to the reduceFn and returns the final value returned by reduceFn
func SelectMap ¶
func SelectMap[T comparable, V any](in map[T]V, f func(i T, j V) bool) map[T]V
func Sign ¶
func Sign[T constraints.Integer | constraints.Float](x T) T
func Sort ¶
func Sort[T constraints.Ordered](in []T) []T
func SubSlice ¶
func SubSlice[T comparable](a, b []T) []T
func Sum ¶
func Sum[T constraints.Integer | constraints.Float](in []T) T
Sum returns the sum of values in the input slice
func Tally ¶
func Tally[T comparable](in []T) map[T]int
Tally takes a slice of comparable items and returns a map with a tally of the number of times each item appears in the slice
func Union ¶
func Union[T comparable](x []T, y []T) []T
Union return a slice of the unique union of the input slices