Documentation
¶
Index ¶
- func Append[T any](as1, as2 []T) []T
- func Appender[T any](s T, as []T) []T
- func ArrayEquality[T any](aa []T, bb []T, equality func(l, r T) bool) bool
- func Concat[A any](l [][]A) []A
- func Contains[T any](source []T, contains T, equality func(l, r T) bool) bool
- func ContainsAllOf[T any](source []T, contains []T, equality func(l, r T) bool) bool
- func Filter[T any](as []T, p func(T) bool) []T
- func FlatMap[T1, T2 any](as []T1, f func(T1) []T2) []T2
- func FoldLeft[T1, T2 any](as []T1, z T2, f func(T2, T1) T2) T2
- func FoldRight[T1, T2 any](as []T1, z T2, f func(T1, T2) T2) T2
- func Map[T1, T2 any](as []T1, f func(T1) T2) []T2
- func Reverse[T1 any](xs []T1) []T1
- func Zero[T any]() []T
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Append ¶
func Append[T any](as1, as2 []T) []T
The efficiency of this algorithm is O(N) Appends as2 to the end of as1
func ArrayEquality ¶ added in v0.1.16
The efficiency of this algorithm is O(N)
func Concat ¶
func Concat[A any](l [][]A) []A
The efficiency of this algorithm is O(N) Collapses the given array of arrays without changing the order.
func ContainsAllOf ¶
The efficiency of this algorithm is O(N)
func FlatMap ¶
func FlatMap[T1, T2 any](as []T1, f func(T1) []T2) []T2
Similar to Map in that it takes an array of T1 and applies a function to each element. But FlatMap is more powerful than map. We can use flatMap to generate a collection that is either larger or smaller than the original input. The efficiency of this algorithm is O(N squared)
func FoldLeft ¶ added in v0.1.13
func FoldLeft[T1, T2 any](as []T1, z T2, f func(T2, T1) T2) T2
This is a stack-safe, tail recursive, pure function that uses the trampoline technique to ensure that the runtime does not face recursion that is too deep(i.e. The garbage collector will run before the recursion gets deep enough to blow the stack). See https://trinetri.wordpress.com/2015/04/28/tail-call-thunks-and-trampoline-in-golang/ A tail call is a function call that is the last action performed in a function. The efficiency of this algorithm is O(N) and it does not reverse the list like FoldRight does. Most of the other array functions in this package use FoldLeft and thus all are stack-safe.
func FoldRight ¶
func FoldRight[T1, T2 any](as []T1, z T2, f func(T1, T2) T2) T2
The efficiency of this algorithm is O(N) but it reverses the list. Use FoldLeft instead if you don't want this.
Types ¶
This section is empty.