Documentation ¶
Index ¶
- Variables
- func All[T comparable](match T, elems ...T) bool
- func AllFn[T any](fn func(int, T) bool, elems ...T) bool
- func AllFnErr[T any](fn func(int, T) (bool, error), elems ...T) (bool, error)
- func Chunk[T any](size int, elems ...T) [][]T
- func Contains[T comparable](match T, elems ...T) bool
- func ContainsFn[T any](fn func(int, T) bool, elems ...T) bool
- func ContainsFnErr[T any](fn func(int, T) (bool, error), elems ...T) (bool, error)
- func Deduplicate[T comparable](elems ...T) []T
- func DeduplicateFn[T any, C comparable](fn func(int, T) C, elems ...T) []T
- func DeduplicateFnErr[T any, C comparable](fn func(int, T) (C, error), elems ...T) ([]T, error)
- func Difference[T comparable](as, bs []T) []T
- func DifferenceFn[T any, C comparable](fn func(int, T) C, as, bs []T) []T
- func DifferenceFnErr[T any, C comparable](fn func(int, T) (C, error), as, bs []T) ([]T, error)
- func Duplicate[T any](count int, elems ...T) []T
- func Each[T any](fn func(int, T), elems ...T)
- func EachErr[T any](fn func(int, T) error, elems ...T) error
- func End[T any](elems ...T) (T, bool)
- func Equals[T comparable](as, bs []T) bool
- func EqualsFn[T any, C comparable](fn func(int, T) C, as, bs []T) bool
- func EqualsFnErr[T any, C comparable](fn func(int, T) (C, error), as, bs []T) (bool, error)
- func Exist[T comparable](s T, elems ...T) bool
- func ExistFn[T any](fn func(int, T) bool, elems ...T) bool
- func ExistFnErr[T any](fn func(int, T) (bool, error), elems ...T) (bool, error)
- func Filter[T any](fn func(int, T) bool, elems ...T) []T
- func FilterErr[T any](fn func(int, T) (bool, error), elems ...T) ([]T, error)
- func Find[T comparable](match T, elems ...T) (T, bool)
- func FindFn[T any](fn func(int, T) bool, elems ...T) (T, bool)
- func FindFnErr[T any](fn func(int, T) (bool, error), elems ...T) (T, bool, error)
- func First[T any](elems ...T) (T, bool)
- func Flatten[T any](elems ...[]T) []T
- func Fold[T any, R any](fn func(int, R, T) R, initial R, elems ...T) R
- func FoldErr[T any, R any](fn func(int, R, T) (R, error), initial R, elems ...T) (R, error)
- func FoldLeft[T any, R any](fn func(int, R, T) R, initial R, elems ...T) R
- func FoldLeftErr[T any, R any](fn func(int, R, T) (R, error), initial R, elems ...T) (R, error)
- func FoldRight[T any, R any](fn func(int, R, T) R, initial R, elems ...T) R
- func FoldRightErr[T any, R any](fn func(int, R, T) (R, error), initial R, elems ...T) (R, error)
- func Group[T any, C comparable](fn func(int, T) C, elems ...T) map[C][]T
- func GroupErr[T any, C comparable](fn func(int, T) (C, error), elems ...T) (map[C][]T, error)
- func HasIntersection[T comparable](as []T, bs []T) bool
- func HasIntersectionFn[T any, C comparable](fn func(T) C, as []T, bs []T) bool
- func HasIntersectionFnErr[T any, C comparable](fn func(T) (C, error), as []T, bs []T) (bool, error)
- func Head[T any](elems ...T) (T, bool)
- func Intersection[T comparable](as []T, bs []T) []T
- func IntersectionFn[T any, C comparable](fn func(T) C, as []T, bs []T) []T
- func IntersectionFnErr[T any, C comparable](fn func(T) (C, error), as []T, bs []T) ([]T, error)
- func Join[T any](sep string, elems ...T) string
- func JoinErrFn[T any](fn func(int, T) (string, error), sep string, elems ...T) (string, error)
- func JoinFn[T any](fn func(int, T) string, sep string, elems ...T) string
- func Last[T any](elems ...T) (T, bool)
- func Map[T any, R any](fn func(int, T) R, elems ...T) []R
- func MapErr[T any, R any](fn func(int, T) (R, error), elems ...T) ([]R, error)
- func MapPipe[T any, R any](fns []func(int, T) R, elems ...T) []R
- func MapPipeErr[T any, R any](fns []func(int, T) (R, error), elems ...T) ([]R, error)
- func Partition[T any](fn func(int, T) bool, elems ...T) ([]T, []T)
- func PartitionErr[T any](fn func(int, T) (bool, error), elems ...T) ([]T, []T, error)
- func Prepend[T any](slice []T, elems ...T) []T
- func Reduce[T any, R any](fn func(int, R, T) R, initial R, elems ...T) R
- func ReduceErr[T any, R any](fn func(int, R, T) (R, error), initial R, elems ...T) (R, error)
- func Reject[T any](fn func(int, T) bool, elems ...T) []T
- func RejectErr[T any](fn func(int, T) (bool, error), elems ...T) ([]T, error)
- func Reverse[T any](elems ...T) []T
- func Sort[T constraints.Ordered](elems ...T) []T
- func SortFn[T any, O constraints.Ordered](fn func(T) O, elems ...T) []T
- func SymmetricDifference[T comparable](as, bs []T) []T
- func SymmetricDifferenceFn[T any, C comparable](fn func(int, T) C, as, bs []T) []T
- func SymmetricDifferenceFnErr[T any, C comparable](fn func(int, T) (C, error), as, bs []T) ([]T, error)
- func Tail[T any](elems ...T) ([]T, bool)
- func Times[T any](count int, elems ...T) []T
- func Union[T comparable](as []T, bs []T) ([]T, error)
- func UnionFn[T any, C comparable](fn func(int, T) C, as []T, bs []T) ([]T, error)
- func UnionFnErr[T any, C comparable](fn func(int, T) (C, error), as []T, bs []T) ([]T, error)
- func Uniq[C comparable](elems ...C) []C
- func UniqFn[T any, C comparable](fn func(int, T) C, elems ...T) []T
- func UniqFnErr[T any, C comparable](fn func(int, T) (C, error), elems ...T) ([]T, error)
- type CountDuplicatesResult
- type Pipe
- type PipeErr
Constants ¶
This section is empty.
Variables ¶
var (
ErrGroup = errors.New("parition error")
)
var (
ErrPartition = errors.New("parition error")
)
var (
ErrReduceExit = errors.New("reduce exit")
)
Functions ¶
func All ¶
func All[T comparable](match T, elems ...T) bool
All[T] test if the match value is equal to all elements in elems
func AllFn ¶
All[T] test if the result of fn(int, T) evaluates to true for all elements in elems
The fn(int, T) bool functions takes:
- int is the index of the current element
- T is the current element
func AllFnErr ¶
All[T] test if the result of fn(int, T) evaluates to true for all elements in elems
The fn(int, T) bool functions takes:
- int is the index of the current element
- T is the current element
If the fn function returns an error, processing through elems is stopped and the error is returned.
func Chunk ¶
Chunk creates a slice where each element is a slice of elems of size length.
If elems can't be split evenly, the final element will contain the remaining elems. If count < 1 the results are return as if count is 1
Example:
elems := []int{1, 2, 3, 4, 5} size := 2 chunks := Chunk(size, elems...) fmt.Println(chunks) // [[1 2] [3 4] [5]]
func Contains ¶
func Contains[T comparable](match T, elems ...T) bool
Contains[T] test if the match value is equal to any of the elements in elems
func ContainsFn ¶
Contains[T] test if the value returned from fn is true for any of the elements in elems
The fn(int, T) bool functions takes:
- int is the index of the current element
- T is the current element
func ContainsFnErr ¶
Contains[T] test if the value returned from fn is true for any of the elements in elems
The fn(int, T) bool functions takes:
- int is the index of the current element
- T is the current element
If the fn function returns an error, processing through elems is stopped and the error is returned.
func Deduplicate ¶ added in v1.0.33
func Deduplicate[T comparable](elems ...T) []T
Deduplicate[T] creates a copy of elems with duplicates removed
func DeduplicateFn ¶ added in v1.0.33
func DeduplicateFn[T any, C comparable](fn func(int, T) C, elems ...T) []T
DeduplicateFn[T, K] creates a copy of elems with duplicates removed based on the result of the fn(int, T) function
The fn(int, T) K functions takes:
- int is the index of the current element
- T is the current element
- K the comparable type to deduplicate
func DeduplicateFnErr ¶ added in v1.0.33
func DeduplicateFnErr[T any, C comparable](fn func(int, T) (C, error), elems ...T) ([]T, error)
DedupFn[T, K] creates a copy of elems with duplicates removed based on the result of the fn(int, T) function
The fn(int, T) K functions takes:
- int is the index of the current element
- T is the current element
- K the comparable type to deduplicate
If the fn function returns an error, processing through elems is stopped and the error is returned.
func Difference ¶ added in v1.0.33
func Difference[T comparable](as, bs []T) []T
func DifferenceFn ¶ added in v1.0.33
func DifferenceFn[T any, C comparable](fn func(int, T) C, as, bs []T) []T
func DifferenceFnErr ¶ added in v1.0.33
func DifferenceFnErr[T any, C comparable](fn func(int, T) (C, error), as, bs []T) ([]T, error)
func Equals ¶
func Equals[T comparable](as, bs []T) bool
func EqualsFnErr ¶
func Exist ¶
func Exist[T comparable](s T, elems ...T) bool
func Find ¶
func Find[T comparable](match T, elems ...T) (T, bool)
func FoldLeftErr ¶
func FoldRightErr ¶
func Group ¶ added in v1.0.33
func Group[T any, C comparable](fn func(int, T) C, elems ...T) map[C][]T
Group creates a map composed of keys generated from the fn function and the value is the value passed to the fn function which genereated they key.
func GroupErr ¶ added in v1.0.33
func GroupErr[T any, C comparable](fn func(int, T) (C, error), elems ...T) (map[C][]T, error)
GroupErr creates a map composed of keys generated from the fn function and the value is the value passed to the fn function which genereated they key.
If the fn function returns an error, processing through elements is stopped and the error is returned. The values of the grouped elements will contain any elements processed up to but not including the element when the error occured.
func HasIntersection ¶ added in v1.0.33
func HasIntersection[T comparable](as []T, bs []T) bool
func HasIntersectionFn ¶ added in v1.0.33
func HasIntersectionFn[T any, C comparable](fn func(T) C, as []T, bs []T) bool
func HasIntersectionFnErr ¶ added in v1.0.33
func HasIntersectionFnErr[T any, C comparable](fn func(T) (C, error), as []T, bs []T) (bool, error)
func Intersection ¶ added in v1.0.33
func Intersection[T comparable](as []T, bs []T) []T
func IntersectionFn ¶ added in v1.0.33
func IntersectionFn[T any, C comparable](fn func(T) C, as []T, bs []T) []T
func IntersectionFnErr ¶ added in v1.0.33
func IntersectionFnErr[T any, C comparable](fn func(T) (C, error), as []T, bs []T) ([]T, error)
func MapPipeErr ¶
func Partition ¶ added in v1.0.33
PartitionErr splits the elements into two slices based on the result of the fn function.
The fn function takes the index of the current index of the element of elems, and the current value of the element in elems. It should return the computed compariable value extract from the element.
The first slice contains the elements for which the fn function returns a true value. The second slice contains the elements for which the fn function returns a false value.
for which the fn function returns a true value. The second slice contains the elems for which the fn fucntion returns a false value.
func PartitionErr ¶ added in v1.0.33
PartitionErr splits the elements into two slices based on the result of the fn function.
The fn function takes the index of the current index of the element of elems, and the current value of the element in elems. It should return the computed compariable value extract from the element or an error if computed compariable value can't be computed.
The first slice contains the elements for which the fn function returns a true value. The second slice contains the elements for which the fn function returns a false value.
If the fn function returns an error, processing through elements is stopped and the error is returned. The values of the partitions will contain any partitioned data up to but not including the value when the error occured.
func Sort ¶
func Sort[T constraints.Ordered](elems ...T) []T
func SortFn ¶ added in v1.0.29
func SortFn[T any, O constraints.Ordered](fn func(T) O, elems ...T) []T
func SymmetricDifference ¶ added in v1.0.33
func SymmetricDifference[T comparable](as, bs []T) []T
func SymmetricDifferenceFn ¶ added in v1.0.33
func SymmetricDifferenceFn[T any, C comparable](fn func(int, T) C, as, bs []T) []T
func SymmetricDifferenceFnErr ¶ added in v1.0.33
func SymmetricDifferenceFnErr[T any, C comparable](fn func(int, T) (C, error), as, bs []T) ([]T, error)
func Union ¶ added in v1.0.33
func Union[T comparable](as []T, bs []T) ([]T, error)
func UnionFn ¶ added in v1.0.33
func UnionFn[T any, C comparable](fn func(int, T) C, as []T, bs []T) ([]T, error)
func UnionFnErr ¶ added in v1.0.33
func UnionFnErr[T any, C comparable](fn func(int, T) (C, error), as []T, bs []T) ([]T, error)
func Uniq ¶ added in v1.0.32
func Uniq[C comparable](elems ...C) []C
func UniqFn ¶ added in v1.0.32
func UniqFn[T any, C comparable](fn func(int, T) C, elems ...T) []T
Types ¶
type CountDuplicatesResult ¶ added in v1.0.33
func CountDuplicates ¶ added in v1.0.33
func CountDuplicates[T comparable](elems ...T) []CountDuplicatesResult[T]
func CountDuplicatesFn ¶ added in v1.0.33
func CountDuplicatesFn[T any, C comparable](fn func(T) C, elems ...T) []CountDuplicatesResult[T]
func CountDuplicatesFnErr ¶ added in v1.0.33
func CountDuplicatesFnErr[T any, C comparable](fn func(T) (C, error), elems ...T) ([]CountDuplicatesResult[T], error)
type PipeErr ¶
type PipeErr[T any] struct { // contains filtered or unexported fields }
func NewPipeErr ¶
Source Files ¶
- all.go
- chunk.go
- contains.go
- count_duplicates.go
- deduplicate.go
- difference.go
- duplicate.go
- each.go
- equals.go
- exist.go
- filter.go
- find.go
- flatten.go
- fold.go
- group.go
- head.go
- intersection.go
- join.go
- last.go
- map.go
- partition.go
- pipe.go
- prepend.go
- reduce.go
- reject.go
- reverse.go
- sort.go
- symmetric_difference.go
- tail.go
- union.go
- uniq.go