collections

package
v0.6.194 Latest Latest
Warning

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

Go to latest
Published: Dec 15, 2022 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Accumulate added in v0.6.124

func Accumulate[T any](items []T, accumulator func(T, T) T) T

func AccumulateE added in v0.6.124

func AccumulateE[T any](items []T, accumulator func(T, T) (T, error)) (T, error)

func Any

func Any[T any](f func(T) bool, list []T)

func C added in v0.6.53

func C[T any](fns ...func(some T) T) func(some T) T

func C2 added in v0.6.53

func C2[T any, S any, R any](fn1 func(some S) R, fn2 func(some T) S) func(some T) R

func C3 added in v0.6.53

func C3[T any, S any, R any, U any](fn0 func(some R) U, fn1 func(some S) R, fn2 func(some T) S) func(some T) U

func C4 added in v0.6.53

func C4[T any, S any, R any, U any, V any](fn01 func(some U) V, fn0 func(some R) U, fn1 func(some S) R, fn2 func(some T) S) func(some T) V

func C5 added in v0.6.53

func C5[T any, S any, R any, U any, V any, W any](fn02 func(some V) W, fn01 func(some U) V, fn0 func(some R) U, fn1 func(some S) R, fn2 func(some T) S) func(some T) W

func Compose added in v0.6.53

func Compose[T any, S any, R any](fn1 func(some S) R, fn2 func(some T) S) func(some T) R

func Concat

func Concat[T any](left []T, right []T) []T

func Cons added in v0.6.53

func Cons[X any](x X, list []X) []X

func Contains added in v0.6.74

func Contains[T comparable](s []T, e T) bool

func ContainsDuplicatesErr added in v0.6.124

func ContainsDuplicatesErr[T comparable](list []T) error

func DefaultPtr added in v0.6.124

func DefaultPtr[T any](value *T, defaultValue T) T

func DefaultPtrOrValue added in v0.6.124

func DefaultPtrOrValue[T any](value *T, defaultValue T) T

return default if ptr is nil or de-referenced ptr value is empty

func DefaultValue added in v0.6.124

func DefaultValue[T any](value T, defaultValue T) T

func Deref added in v0.6.124

func Deref[T any](x *T) T

func DictMerge

func DictMerge[K comparable, V any](left map[K]V, right map[K]V) map[K]V

func Difference

func Difference[T comparable](from []T, remove []T) []T

func Duplicate

func Duplicate[T any](x T) []T

func Enconcat added in v0.6.53

func Enconcat[X any](before []X, x X, after []X) []X

func Fanout

func Fanout[T any, R any](fs []func(T) R, item T) []R

func Filter

func Filter[T any](fn func(some T) bool, list []T) []T

func FilterEmpty added in v0.6.74

func FilterEmpty[T comparable](l []T) []T

func Find added in v0.6.124

func Find[T any](list []*T, f func(*T) bool) *T

func First added in v0.6.53

func First[X any](list []X) *X

func Flatmap

func Flatmap[T any, R any](fn func(some T) []R, list []T) []R

func FlatmapE added in v0.6.124

func FlatmapE[T any, R any](fn func(some T) ([]R, error), list []T) ([]R, error)

Take a list of things and a function that returns a list of things then combines list after mapping (return early from error) func T -> [R, R, R ...] [T, T, T ...] -> [R, R, R ...]

func Flatten added in v0.6.124

func Flatten[T any](listOfLists [][]T) []T

func Flip added in v0.6.53

func Flip[X any, Y any, Z any](fn func(X, Y) Z) func(Y, X) Z

func Fmap

func Fmap[T any, R any](fn func(some T) R, list []T) []R

func Foldl

func Foldl[T any, R any](fn func(acc R, next T) R, base R, list []T) R

func FoldlE added in v0.6.124

func FoldlE[T any, R any](fn func(acc R, next T) (R, error), base R, list []T) (R, error)

func Foldr

func Foldr[T any, R any](fn func(next T, carry R) R, base R, list []T) R

func FromJSON added in v0.6.124

func FromJSON[T any](j []byte) (T, error)

func GetAValueFromMap added in v0.6.124

func GetAValueFromMap[K comparable, V any](m map[K]V) *V

func GetMapKeys added in v0.6.124

func GetMapKeys[K comparable, V any](m map[K]V) []K

func GetMapValues added in v0.6.124

func GetMapValues[K comparable, V any](m map[K]V) []V

func Id added in v0.6.53

func Id[T any](x T) T

func InitialNotEqual added in v0.6.124

func InitialNotEqual[T any](i T) func(l T) bool

func IsEmpty added in v0.6.124

func IsEmpty[T any](x T) bool

func IsEmptyValP added in v0.6.124

func IsEmptyValP[T any](x *T) bool

func Keys added in v0.6.53

func Keys[T comparable, R any](dict map[T]R) []T

func ListContains added in v0.6.124

func ListContains[K comparable](list []K, item K) bool

func ListHas added in v0.6.124

func ListHas[K any](list []K, item K, has func(l, r K) bool) bool

func ListItemsAreErr added in v0.6.124

func ListItemsAreErr[T comparable](items []T, are []T) error

takes a list of items and checks if items are elements in another list

func ListOfPointersToListOfValues added in v0.6.124

func ListOfPointersToListOfValues[T any](list []*T) []T

func ListOfSomethingToListOfAny added in v0.6.124

func ListOfSomethingToListOfAny[T any](l []T) []any

func ManyIntegersToInts added in v0.6.124

func ManyIntegersToInts[T constraints.Integer](i []T) []int

func ManyStringLikeToStrings added in v0.6.124

func ManyStringLikeToStrings[T ~string](i []T) []string

func Map added in v0.6.124

func Map[T, R any](items []T, mapper func(T) R) []R

func T -> R [T, T, T ...] -> [R, R, R ...]

func MapContainsKey added in v0.6.111

func MapContainsKey[K comparable, V any](m map[K]V, key K) bool

func MapE added in v0.6.124

func MapE[T, R any](items []T, mapper func(T) (R, error)) ([]R, error)

func MapFromList added in v0.6.124

func MapFromList[T any, R comparable](list []T, keySelector func(l T) R) map[R]T

func MapToStruct added in v0.6.124

func MapToStruct[T any](m any) (T, error)

pass in m a map of string to any

func MergeMaps added in v0.6.124

func MergeMaps[K comparable, V any](maps ...map[K]V) map[K]V

right maps override left if they have the same key

func P2 added in v0.6.53

func P2[X any, Y any, Z any](fn func(X, Y) Z, x X) func(Y) Z

func Ptr added in v0.6.124

func Ptr[T any](x T) *T

func RemoveDuplicates added in v0.6.124

func RemoveDuplicates[T comparable](list []T) []T

func ReturnOnCondition added in v0.6.124

func ReturnOnCondition[T any](ctx context.Context, fetcher func(ctx context.Context) (T, error), conditional func(i T) bool, updateDuration time.Duration) (T, error)

func S added in v0.6.53

func S[T any](fns ...func(some T) T) func(some T) T

func SortBy added in v0.6.53

func SortBy[X any](sortFn func(X, X) bool, list []X) []X

func ToDict

func ToDict[T comparable](xs []T) map[T]bool

func TryCopyTo added in v0.6.124

func TryCopyTo[T any, R any](t T, r R, options copier.Option) (R, error)

func TryCopyToNew added in v0.6.124

func TryCopyToNew[T any, R any](t T, options copier.Option) (R, error)

func Uniq

func Uniq[T comparable](xs []T) []T

func ValueOrZero added in v0.6.124

func ValueOrZero[T any](ptr *T) T

func ZeroValueToNil added in v0.6.124

func ZeroValueToNil[T any](x T) *T

return value or nil if value is zero

Types

type Params added in v0.6.124

type Params[T any] struct {
	Value T
	Ctx   context.Context
}

type Result added in v0.6.124

type Result[T any] struct {
	Value T
	Err   error
}

func (Result[T]) Unwrap added in v0.6.124

func (r Result[T]) Unwrap() (T, error)

Jump to

Keyboard shortcuts

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