generic

package
v1.0.39 Latest Latest
Warning

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

Go to latest
Published: Sep 26, 2023 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Ap added in v1.0.4

func Ap[BS ~[]B, ABS ~[]func(A) B, AS ~[]A, B, A any](fa AS) func(ABS) BS

func Append

func Append[GA ~[]A, A any](as GA, a A) GA

func Chain added in v1.0.4

func Chain[AS ~[]A, BS ~[]B, A, B any](f func(A) BS) func(AS) BS

func Copy added in v1.0.9

func Copy[AS ~[]A, A any](b AS) AS

func Empty

func Empty[GA ~[]A, A any]() GA

func FilterChain added in v1.0.15

func FilterChain[GA ~[]A, GB ~[]B, A, B any](f func(a A) O.Option[GB]) func(GA) GB

func FilterMap

func FilterMap[GA ~[]A, GB ~[]B, A, B any](f func(a A) O.Option[B]) func(GA) GB

func First

func First[GA ~[]A, A any](as GA) O.Option[A]

func Flap added in v1.0.39

func Flap[FAB ~func(A) B, GFAB ~[]FAB, GB ~[]B, A, B any](a A) func(GFAB) GB

func Flatten added in v1.0.15

func Flatten[GAA ~[]GA, GA ~[]A, A any](mma GAA) GA

func Fold added in v1.0.16

func Fold[AS ~[]A, A any](m M.Monoid[A]) func(AS) A

func FoldMap added in v1.0.16

func FoldMap[AS ~[]A, A, B any](m M.Monoid[B]) func(func(A) B) func(AS) B

func From

func From[GA ~[]A, A any](data ...A) GA

From constructs an array from a set of variadic arguments

func Head[GA ~[]A, A any](as GA) O.Option[A]

func IsEmpty added in v1.0.6

func IsEmpty[AS ~[]A, A any](as AS) bool

func IsNil added in v1.0.28

func IsNil[GA ~[]A, A any](as GA) bool

func IsNonNil added in v1.0.28

func IsNonNil[GA ~[]A, A any](as GA) bool

func Last

func Last[GA ~[]A, A any](as GA) O.Option[A]

func Lookup

func Lookup[GA ~[]A, A any](idx int) func(GA) O.Option[A]

func MakeBy added in v1.0.4

func MakeBy[AS ~[]A, F ~func(int) A, A any](n int, f F) AS

MakeBy returns a `Array` of length `n` with element `i` initialized with `f(i)`.

func Map added in v1.0.20

func Map[GA ~[]A, GB ~[]B, A, B any](f func(a A) B) func(GA) GB

func Match added in v1.0.6

func Match[AS ~[]A, A, B any](onEmpty func() B, onNonEmpty func(AS) B) func(AS) B

func MatchLeft added in v1.0.6

func MatchLeft[AS ~[]A, A, B any](onEmpty func() B, onNonEmpty func(A, AS) B) func(AS) B

func MonadAp added in v1.0.4

func MonadAp[BS ~[]B, ABS ~[]func(A) B, AS ~[]A, B, A any](fab ABS, fa AS) BS

func MonadChain added in v1.0.4

func MonadChain[AS ~[]A, BS ~[]B, A, B any](fa AS, f func(a A) BS) BS

func MonadFilterMap

func MonadFilterMap[GA ~[]A, GB ~[]B, A, B any](fa GA, f func(a A) O.Option[B]) GB

func MonadFlap added in v1.0.39

func MonadFlap[FAB ~func(A) B, GFAB ~[]FAB, GB ~[]B, A, B any](fab GFAB, a A) GB

func MonadMap

func MonadMap[GA ~[]A, GB ~[]B, A, B any](as GA, f func(a A) B) GB

func MonadPartition

func MonadPartition[GA ~[]A, A any](as GA, pred func(A) bool) tuple.Tuple2[GA, GA]

func Of

func Of[GA ~[]A, A any](value A) GA

Of constructs a single element array

func Partition

func Partition[GA ~[]A, A any](pred func(A) bool) func(GA) tuple.Tuple2[GA, GA]

func Push added in v1.0.20

func Push[GA ~[]A, A any](a A) func(GA) GA

func Reduce added in v1.0.20

func Reduce[GA ~[]A, A, B any](fa GA, f func(B, A) B, initial B) B

func ReduceWithIndex added in v1.0.20

func ReduceWithIndex[GA ~[]A, A, B any](fa GA, f func(int, B, A) B, initial B) B

func Replicate added in v1.0.4

func Replicate[AS ~[]A, A any](n int, a A) AS

func Size

func Size[GA ~[]A, A any](as GA) int

func Slice added in v1.0.9

func Slice[AS ~[]A, A any](start int, end int) func(AS) AS

func SliceRight added in v1.0.9

func SliceRight[AS ~[]A, A any](start int) func(AS) AS

func Sort

func Sort[GA ~[]T, T any](ord O.Ord[T]) func(ma GA) GA

Sort implements a stable sort on the array given the provided ordering

func SortBy added in v1.0.19

func SortBy[GA ~[]T, GO ~[]O.Ord[T], T any](ord GO) func(ma GA) GA

SortBy implements a stable sort on the array given the provided ordering

func SortByKey added in v1.0.16

func SortByKey[GA ~[]T, K, T any](ord O.Ord[K], f func(T) K) func(ma GA) GA

SortByKey implements a stable sort on the array given the provided ordering on an extracted key

func Tail

func Tail[GA ~[]A, A any](as GA) O.Option[GA]

func Unzip added in v1.0.11

func Unzip[AS ~[]A, BS ~[]B, CS ~[]T.Tuple2[A, B], A, B any](cs CS) T.Tuple2[AS, BS]

Unzip is the function is reverse of Zip. Takes an array of pairs and return two corresponding arrays

func UpsertAt

func UpsertAt[GA ~[]A, A any](a A) func(GA) GA

func Zip added in v1.0.11

func Zip[AS ~[]A, BS ~[]B, CS ~[]T.Tuple2[A, B], A, B any](fb BS) func(AS) CS

Zip takes two arrays and returns an array of corresponding pairs. If one input array is short, excess elements of the longer array are discarded

func ZipWith added in v1.0.11

func ZipWith[AS ~[]A, BS ~[]B, CS ~[]C, FCT ~func(A, B) C, A, B, C any](fa AS, fb BS, f FCT) CS

ZipWith applies a function to pairs of elements at the same index in two arrays, collecting the results in a new array. If one input array is short, excess elements of the longer array are discarded.

Types

This section is empty.

Jump to

Keyboard shortcuts

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