Documentation
¶
Index ¶
- func Chunk[T any](slice []T, chunkSize int) [][]T
- func Filter[T any](in []T, keep func(T) bool) (out []T)
- func FilterInPlace[T any](in []T, keep func(T) bool) (out []T)
- func Map[I, O any](data []I, mapFunc func(I) O) []O
- func MapToMap[I any, O comparable, U any](data []I, mapFunc func(I) (O, U)) map[O]U
- func ReverseOf[T any](s []T) []T
- func ScanLeft[T constraints.Ordered](data []T, init T, op func(T, T) T) []T
- func Sliding[T any](data []T, groupSize int) [][]T
- func Unique[T comparable](in []T) []T
- func UniqueInPlace[T comparable](in []T) []T
- func Zip[T any](L, R []T) [][2]T
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Chunk ¶
Chunk takes a slice of values and a chunkSize, then returns a slice of the values in slices of chunkSize ex: Chunk({1,2,3,4,5,6,7,8},3) == {{1,2,3}{4,5,6}{7,8}}
func Filter ¶
Filter applies the keep function to each value in the input The result is a slice of only the values which returned true
func FilterInPlace ¶
TODO: changeMe The result is a slice of only the values which returned true
func Map ¶
func Map[I, O any](data []I, mapFunc func(I) O) []O
Map returns a same-sized slice as the input data.
The value of each position in the output slice is the same position in the input slice modified by the mapFunc.
e.x. output[i] == mapFunc(data[i])
func MapToMap ¶
func MapToMap[I any, O comparable, U any](data []I, mapFunc func(I) (O, U)) map[O]U
MapToMap // TODO: this
func ScanLeft ¶
func ScanLeft[T constraints.Ordered](data []T, init T, op func(T, T) T) []T
ScanLeft creates a slice of size len(data)+1, where the first item is init. All other values in the output are the result of the provided operation
func Sliding ¶
Sliding takes an input slice and a groupsize. ex: sliding({1,2,3,4,5,6,7},3) == {{1,2,3}, For each value in the slice that has groupsize-1 values after it, {2,3,4}, add a slice of {data[i], data[i+1],...,data[i+groupsize-1]} to the output {3,4,5},
func Unique ¶
func Unique[T comparable](in []T) []T
func UniqueInPlace ¶
func UniqueInPlace[T comparable](in []T) []T
UniqueInPlace modifies the input! The output may be a different size than the input!
Types ¶
This section is empty.