package generic
import "github.com/IBM/fp-go/array/generic"
Index ¶
- func Any[AS ~[]A, PRED ~func(A) bool, A any](pred PRED) func(AS) bool
- func AnyWithIndex[AS ~[]A, PRED ~func(int, A) bool, A any](pred PRED) func(AS) bool
- func Ap[BS ~[]B, ABS ~[]func(A) B, AS ~[]A, B, A any](fa AS) func(ABS) BS
- func ApS[GS1 ~[]S1, GS2 ~[]S2, GT ~[]T, S1, S2, T any]( setter func(T) func(S1) S2, fa GT, ) func(GS1) GS2
- func Append[GA ~[]A, A any](as GA, a A) GA
- func Bind[GS1 ~[]S1, GS2 ~[]S2, GT ~[]T, S1, S2, T any]( setter func(T) func(S1) S2, f func(S1) GT, ) func(GS1) GS2
- func BindTo[GS1 ~[]S1, GT ~[]T, S1, T any]( setter func(T) S1, ) func(GT) GS1
- func Chain[AS ~[]A, BS ~[]B, A, B any](f func(A) BS) func(AS) BS
- func Clone[AS ~[]A, A any](f func(A) A) func(as AS) AS
- func Copy[AS ~[]A, A any](b AS) AS
- func Do[GS ~[]S, S any]( empty S, ) GS
- func Empty[GA ~[]A, A any]() GA
- func Filter[AS ~[]A, PRED ~func(A) bool, A any](pred PRED) func(AS) AS
- func FilterChain[GA ~[]A, GB ~[]B, A, B any](f func(a A) O.Option[GB]) func(GA) GB
- func FilterMap[GA ~[]A, GB ~[]B, A, B any](f func(A) O.Option[B]) func(GA) GB
- func FilterMapWithIndex[GA ~[]A, GB ~[]B, A, B any](f func(int, A) O.Option[B]) func(GA) GB
- func FilterWithIndex[AS ~[]A, PRED ~func(int, A) bool, A any](pred PRED) func(AS) AS
- func FindFirst[AS ~[]A, PRED ~func(A) bool, A any](pred PRED) func(AS) O.Option[A]
- func FindFirstMap[AS ~[]A, PRED ~func(A) O.Option[B], A, B any](pred PRED) func(AS) O.Option[B]
- func FindFirstMapWithIndex[AS ~[]A, PRED ~func(int, A) O.Option[B], A, B any](pred PRED) func(AS) O.Option[B]
- func FindFirstWithIndex[AS ~[]A, PRED ~func(int, A) bool, A any](pred PRED) func(AS) O.Option[A]
- func FindLast[AS ~[]A, PRED ~func(A) bool, A any](pred PRED) func(AS) O.Option[A]
- func FindLastMap[AS ~[]A, PRED ~func(A) O.Option[B], A, B any](pred PRED) func(AS) O.Option[B]
- func FindLastMapWithIndex[AS ~[]A, PRED ~func(int, A) O.Option[B], A, B any](pred PRED) func(AS) O.Option[B]
- func FindLastWithIndex[AS ~[]A, PRED ~func(int, A) bool, A any](pred PRED) func(AS) O.Option[A]
- func First[GA ~[]A, A any](as GA) O.Option[A]
- func Flap[FAB ~func(A) B, GFAB ~[]FAB, GB ~[]B, A, B any](a A) func(GFAB) GB
- func Flatten[GAA ~[]GA, GA ~[]A, A any](mma GAA) GA
- func Fold[AS ~[]A, A any](m M.Monoid[A]) func(AS) A
- func FoldMap[AS ~[]A, A, B any](m M.Monoid[B]) func(func(A) B) func(AS) B
- func FoldMapWithIndex[AS ~[]A, A, B any](m M.Monoid[B]) func(func(int, A) B) func(AS) B
- func From[GA ~[]A, A any](data ...A) GA
- func Head[GA ~[]A, A any](as GA) O.Option[A]
- func IsEmpty[AS ~[]A, A any](as AS) bool
- func IsNil[GA ~[]A, A any](as GA) bool
- func IsNonNil[GA ~[]A, A any](as GA) bool
- func Last[GA ~[]A, A any](as GA) O.Option[A]
- func Let[GS1 ~[]S1, GS2 ~[]S2, S1, S2, T any]( key func(T) func(S1) S2, f func(S1) T, ) func(GS1) GS2
- func LetTo[GS1 ~[]S1, GS2 ~[]S2, S1, S2, B any]( key func(B) func(S1) S2, b B, ) func(GS1) GS2
- func Lookup[GA ~[]A, A any](idx int) func(GA) O.Option[A]
- func MakeBy[AS ~[]A, F ~func(int) A, A any](n int, f F) AS
- func Map[GA ~[]A, GB ~[]B, A, B any](f func(a A) B) func(GA) GB
- func MapWithIndex[GA ~[]A, GB ~[]B, A, B any](f func(int, A) B) func(GA) GB
- func Match[AS ~[]A, A, B any](onEmpty func() B, onNonEmpty func(AS) B) func(AS) B
- func MatchLeft[AS ~[]A, A, B any](onEmpty func() B, onNonEmpty func(A, AS) B) func(AS) B
- func Monad[A, B any, GA ~[]A, GB ~[]B, GAB ~[]func(A) B]() monad.Monad[A, B, GA, GB, GAB]
- func MonadAp[BS ~[]B, ABS ~[]func(A) B, AS ~[]A, B, A any](fab ABS, fa AS) BS
- func MonadChain[AS ~[]A, BS ~[]B, A, B any](fa AS, f func(a A) BS) BS
- func MonadFilterMap[GA ~[]A, GB ~[]B, A, B any](fa GA, f func(A) O.Option[B]) GB
- func MonadFilterMapWithIndex[GA ~[]A, GB ~[]B, A, B any](fa GA, f func(int, A) O.Option[B]) GB
- func MonadFlap[FAB ~func(A) B, GFAB ~[]FAB, GB ~[]B, A, B any](fab GFAB, a A) GB
- func MonadMap[GA ~[]A, GB ~[]B, A, B any](as GA, f func(a A) B) GB
- func MonadMapWithIndex[GA ~[]A, GB ~[]B, A, B any](as GA, f func(int, A) B) GB
- func MonadPartition[GA ~[]A, A any](as GA, pred func(A) bool) tuple.Tuple2[GA, GA]
- func MonadReduce[GA ~[]A, A, B any](fa GA, f func(B, A) B, initial B) B
- func MonadReduceRight[GA ~[]A, A, B any](fa GA, f func(A, B) B, initial B) B
- func MonadReduceRightWithIndex[GA ~[]A, A, B any](fa GA, f func(int, A, B) B, initial B) B
- func MonadReduceWithIndex[GA ~[]A, A, B any](fa GA, f func(int, B, A) B, initial B) B
- func Of[GA ~[]A, A any](value A) GA
- func Partition[GA ~[]A, A any](pred func(A) bool) func(GA) tuple.Tuple2[GA, GA]
- func Prepend[ENDO ~func(AS) AS, AS []A, A any](head A) ENDO
- func Push[ENDO ~func(GA) GA, GA ~[]A, A any](a A) ENDO
- func Reduce[GA ~[]A, A, B any](f func(B, A) B, initial B) func(GA) B
- func ReduceRight[GA ~[]A, A, B any](f func(A, B) B, initial B) func(GA) B
- func ReduceRightWithIndex[GA ~[]A, A, B any](f func(int, A, B) B, initial B) func(GA) B
- func ReduceWithIndex[GA ~[]A, A, B any](f func(int, B, A) B, initial B) func(GA) B
- func Replicate[AS ~[]A, A any](n int, a A) AS
- func Size[GA ~[]A, A any](as GA) int
- func Slice[AS ~[]A, A any](start int, end int) func(AS) AS
- func SliceRight[AS ~[]A, A any](start int) func(AS) AS
- func Sort[GA ~[]T, T any](ord O.Ord[T]) func(ma GA) GA
- func SortBy[GA ~[]T, GO ~[]O.Ord[T], T any](ord GO) func(ma GA) GA
- func SortByKey[GA ~[]T, K, T any](ord O.Ord[K], f func(T) K) func(ma GA) GA
- func StrictUniq[AS ~[]A, A comparable](as AS) AS
- func Tail[GA ~[]A, A any](as GA) O.Option[GA]
- func Uniq[AS ~[]A, PRED ~func(A) K, A any, K comparable](f PRED) func(as AS) AS
- func Unzip[AS ~[]A, BS ~[]B, CS ~[]T.Tuple2[A, B], A, B any](cs CS) T.Tuple2[AS, BS]
- func UpsertAt[GA ~[]A, A any](a A) func(GA) GA
- func Zip[AS ~[]A, BS ~[]B, CS ~[]T.Tuple2[A, B], A, B any](fb BS) func(AS) CS
- func ZipWith[AS ~[]A, BS ~[]B, CS ~[]C, FCT ~func(A, B) C, A, B, C any](fa AS, fb BS, f FCT) CS
Functions ¶
func Any ¶
Any tests if any of the elements in the array matches the predicate
func AnyWithIndex ¶
AnyWithIndex tests if any of the elements in the array matches the predicate
func Ap ¶
func Ap[BS ~[]B, ABS ~[]func(A) B, AS ~[]A, B, A any](fa AS) func(ABS) BS
func ApS ¶
func ApS[GS1 ~[]S1, GS2 ~[]S2, GT ~[]T, S1, S2, T any]( setter func(T) func(S1) S2, fa GT, ) func(GS1) GS2
ApS attaches a value to a context [S1] to produce a context [S2] by considering the context and the value concurrently
func Append ¶
func Append[GA ~[]A, A any](as GA, a A) GA
func Bind ¶
func Bind[GS1 ~[]S1, GS2 ~[]S2, GT ~[]T, S1, S2, T any]( setter func(T) func(S1) S2, f func(S1) GT, ) func(GS1) GS2
Bind attaches the result of a computation to a context [S1] to produce a context [S2]
func BindTo ¶
func BindTo[GS1 ~[]S1, GT ~[]T, S1, T any]( setter func(T) S1, ) func(GT) GS1
BindTo initializes a new state [S1] from a value [T]
func Chain ¶
func Chain[AS ~[]A, BS ~[]B, A, B any](f func(A) BS) func(AS) BS
func Clone ¶
func Clone[AS ~[]A, A any](f func(A) A) func(as AS) AS
func Copy ¶
func Copy[AS ~[]A, A any](b AS) AS
func Do ¶
func Do[GS ~[]S, S any]( empty S, ) GS
Bind creates an empty context of type [S] to be used with the Bind operation
func Empty ¶
func Empty[GA ~[]A, A any]() GA
func Filter ¶
func FilterChain ¶
func FilterMap ¶
func FilterMapWithIndex ¶
func FilterWithIndex ¶
func FindFirst ¶
FindFirst finds the first element which satisfies a predicate (or a refinement) function
func FindFirstMap ¶
FindFirstMap finds the first element returned by an [O.Option] based selector function
func FindFirstMapWithIndex ¶
func FindFirstMapWithIndex[AS ~[]A, PRED ~func(int, A) O.Option[B], A, B any](pred PRED) func(AS) O.Option[B]
FindFirstMapWithIndex finds the first element returned by an [O.Option] based selector function
func FindFirstWithIndex ¶
FindFirstWithIndex finds the first element which satisfies a predicate (or a refinement) function
func FindLast ¶
FindLast finds the first element which satisfies a predicate (or a refinement) function
func FindLastMap ¶
FindLastMap finds the first element returned by an [O.Option] based selector function
func FindLastMapWithIndex ¶
func FindLastMapWithIndex[AS ~[]A, PRED ~func(int, A) O.Option[B], A, B any](pred PRED) func(AS) O.Option[B]
FindLastMapWithIndex finds the first element returned by an [O.Option] based selector function
func FindLastWithIndex ¶
FindLastWithIndex finds the first element which satisfies a predicate (or a refinement) function
func First ¶
func Flap ¶
func Flap[FAB ~func(A) B, GFAB ~[]FAB, GB ~[]B, A, B any](a A) func(GFAB) GB
func Flatten ¶
func Flatten[GAA ~[]GA, GA ~[]A, A any](mma GAA) GA
func Fold ¶
func FoldMap ¶
func FoldMapWithIndex ¶
func From ¶
func From[GA ~[]A, A any](data ...A) GA
From constructs an array from a set of variadic arguments
func Head ¶
func IsEmpty ¶
func IsNil ¶
func IsNonNil ¶
func Last ¶
func Let ¶
func Let[GS1 ~[]S1, GS2 ~[]S2, S1, S2, T any]( key func(T) func(S1) S2, f func(S1) T, ) func(GS1) GS2
Let attaches the result of a computation to a context [S1] to produce a context [S2]
func LetTo ¶
func LetTo[GS1 ~[]S1, GS2 ~[]S2, S1, S2, B any]( key func(B) func(S1) S2, b B, ) func(GS1) GS2
LetTo attaches the a value to a context [S1] to produce a context [S2]
func Lookup ¶
func MakeBy ¶
MakeBy returns a `Array` of length `n` with element `i` initialized with `f(i)`.
func Map ¶
func Map[GA ~[]A, GB ~[]B, A, B any](f func(a A) B) func(GA) GB
func MapWithIndex ¶
func Match ¶
func Match[AS ~[]A, A, B any](onEmpty func() B, onNonEmpty func(AS) B) func(AS) B
func MatchLeft ¶
func MatchLeft[AS ~[]A, A, B any](onEmpty func() B, onNonEmpty func(A, AS) B) func(AS) B
func Monad ¶
Monad implements the monadic operations for an array
func MonadAp ¶
func MonadAp[BS ~[]B, ABS ~[]func(A) B, AS ~[]A, B, A any](fab ABS, fa AS) BS
func MonadChain ¶
func MonadChain[AS ~[]A, BS ~[]B, A, B any](fa AS, f func(a A) BS) BS
func MonadFilterMap ¶
func MonadFilterMapWithIndex ¶
func MonadFlap ¶
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 MonadMapWithIndex ¶
func MonadPartition ¶
func MonadReduce ¶
func MonadReduce[GA ~[]A, A, B any](fa GA, f func(B, A) B, initial B) B
func MonadReduceRight ¶
func MonadReduceRight[GA ~[]A, A, B any](fa GA, f func(A, B) B, initial B) B
func MonadReduceRightWithIndex ¶
func MonadReduceWithIndex ¶
func Of ¶
func Of[GA ~[]A, A any](value A) GA
Of constructs a single element array
func Partition ¶
func Prepend ¶
func Prepend[ENDO ~func(AS) AS, AS []A, A any](head A) ENDO
func Push ¶
func Push[ENDO ~func(GA) GA, GA ~[]A, A any](a A) ENDO
func Reduce ¶
func Reduce[GA ~[]A, A, B any](f func(B, A) B, initial B) func(GA) B
func ReduceRight ¶
func ReduceRight[GA ~[]A, A, B any](f func(A, B) B, initial B) func(GA) B
func ReduceRightWithIndex ¶
func ReduceWithIndex ¶
func Replicate ¶
func Size ¶
func Slice ¶
func SliceRight ¶
func Sort ¶
Sort implements a stable sort on the array given the provided ordering
func SortBy ¶
SortBy implements a stable sort on the array given the provided ordering
func SortByKey ¶
SortByKey implements a stable sort on the array given the provided ordering on an extracted key
func StrictUniq ¶
func StrictUniq[AS ~[]A, A comparable](as AS) AS
StrictUniq converts an array of arbitrary items into an array or unique items where uniqueness is determined by the built-in uniqueness constraint
func Tail ¶
func Uniq ¶
func Uniq[AS ~[]A, PRED ~func(A) K, A any, K comparable](f PRED) func(as AS) AS
Uniq converts an array of arbitrary items into an array or unique items where uniqueness is determined based on a key extractor function
func Unzip ¶
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 ¶
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 ¶
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.
Source Files ¶
any.go array.go bind.go find.go monad.go sort.go uniq.go zip.go
- Version
- v1.0.151 (latest)
- Published
- Nov 23, 2024
- Platform
- linux/amd64
- Imports
- 12 packages
- Last checked
- 4 months ago –
Tools for package owners.