arrays

package
v0.1.14 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 16, 2022 License: Apache-2.0 Imports: 0 Imported by: 5

Documentation

Index

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)

func Appender

func Appender[T any](s T, as []T) []T

func Concat

func Concat[A any](l [][]A) []A

The efficiency of this algorithm is O(N)

func Contains

func Contains[T any](source []T, contains T, equality func(l, r T) bool) bool

The efficiency of this algorithm is O(N)

func ContainsAllOf

func ContainsAllOf[T any](source []T, contains []T, equality func(l, r T) bool) bool

The efficiency of this algorithm is O(N)

func Filter

func Filter[T any](as []T, p func(T) bool) []T

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

The efficiency of this algorithm is O(N) and it does not reverse the list like FoldRight does. TODO Make this function tail-recursive

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.

func Map

func Map[T1, T2 any](as []T1, f func(T1) T2) []T2

A structure-preserving Functor on the given array of T. The efficiency of this algorithm is O(N)

func Reverse

func Reverse[T1 any](xs []T1) []T1

The efficiency of this algorithm is O(N)

func SetEquality

func SetEquality[T any](aa []T, bb []T, equality func(l, r T) bool) bool

The efficiency of this algorithm is O(N)

func SetIntersection

func SetIntersection[T any](a []T, b []T, equality func(l, r T) bool) []T

Returns the intersection of set 'a' and 'b' The efficiency of this algorithm is O(5 * N)

func SetMinus

func SetMinus[T any](a []T, b []T, equality func(l, r T) bool) []T

Returns the set 'a' minus set 'b' The efficiency of this algorithm is O(N)

func SetUnion

func SetUnion[T any](a []T, b []T) []T

Returns the set union of set 'a' and 'b' The efficiency of this algorithm is O(N)

func Zero

func Zero[T any]() []T

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL