slicer

package
v1.0.29 Latest Latest
Warning

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

Go to latest
Published: Dec 7, 2023 License: MIT Imports: 4 Imported by: 6

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func All

func All[T comparable](match T, items ...T) bool

func AllFn

func AllFn[T any](fn func(T) bool, items ...T) bool

func AllFnErr

func AllFnErr[T any](fn func(T) (bool, error), items ...T) (bool, error)

func AllFnErrI

func AllFnErrI[T any](fn func(int, T) (bool, error), items ...T) (bool, error)

func AllFnI

func AllFnI[T any](fn func(int, T) bool, items ...T) bool

func Chunk

func Chunk[T any](size int, items ...T) [][]T

func Contains

func Contains[T comparable](match T, items ...T) bool

func ContainsFn

func ContainsFn[T any](fn func(T) bool, items ...T) bool

func ContainsFnErr

func ContainsFnErr[T any](fn func(T) (bool, error), items ...T) (bool, error)

func ContainsFnErrI

func ContainsFnErrI[T any](fn func(int, T) (bool, error), items ...T) (bool, error)

func ContainsFnI

func ContainsFnI[T any](fn func(int, T) bool, items ...T) bool

func Copy

func Copy[T any](items ...T) []T

func Dedup

func Dedup[T comparable](items ...T) []T

func DedupFn

func DedupFn[T any, K comparable](fn func(T) K, items ...T) []T

func DedupFnErr

func DedupFnErr[T any, K comparable](fn func(T) (K, error), items ...T) ([]T, error)

func Diff

func Diff[T comparable](as, bs []T) []T

func DiffFn

func DiffFn[T any](as, bs []T, fn func(T, T) bool) []T

func DiffFnErr

func DiffFnErr[T any](as, bs []T, fn func(T, T) (bool, error)) ([]T, error)

func Each

func Each[T any](fn func(T), items ...T)

func EachErr

func EachErr[T any](fn func(T) error, items ...T) error

func Equals

func Equals[T comparable](as, bs []T) bool

func EqualsFn

func EqualsFn[T comparable](as, bs []T, fn func(T, T) bool) bool

func EqualsFnErr

func EqualsFnErr[T comparable](as, bs []T, fn func(T, T) (bool, error)) (bool, error)

func Exist

func Exist[T comparable](s T, items ...T) bool

func ExistFn

func ExistFn[T any](fn func(T) bool, items ...T) bool

func ExistFnErr

func ExistFnErr[T any](fn func(T) (bool, error), items ...T) (bool, error)

func Filter

func Filter[T any](fn func(T) bool, items ...T) []T

func FilterErr

func FilterErr[T any](fn func(T) (bool, error), items ...T) ([]T, error)

func Find

func Find[T comparable](match T, items ...T) (T, bool)

func FindFn

func FindFn[T any](fn func(T) bool, items ...T) (T, bool)

func FindFnErr

func FindFnErr[T any](fn func(T) (bool, error), items ...T) (T, bool, error)

func FirstNotZero

func FirstNotZero[T comparable](items ...T) (T, bool)

func FirstZero

func FirstZero[T comparable](items ...T) (T, bool)

func Flatten

func Flatten[T any](items ...[]T) []T

func FlattenFn

func FlattenFn[T any, U any](fn func(vs []T) []U, items ...[]T) []U

func FlattenFnErr

func FlattenFnErr[T any, U any](fn func(vs []T) ([]U, error), items ...[]T) ([]U, error)

func FoldLeft

func FoldLeft[I any, O any](initial O, fn func(O, I) O, items ...I) O

func FoldLeftErr

func FoldLeftErr[I any, O any](initial O, fn func(O, I) (O, error), items ...I) (O, error)

func FoldLeftErrI

func FoldLeftErrI[I any, O any](initial O, fn func(int, O, I) (O, error), items ...I) (O, error)

func FoldLeftI

func FoldLeftI[I any, O any](initial O, fn func(int, O, I) O, items ...I) O

func FoldRight

func FoldRight[I any, O any](initial O, fn func(O, I) O, items ...I) O

func FoldRightErr

func FoldRightErr[I any, O any](initial O, fn func(O, I) (O, error), items ...I) (O, error)

func FoldRightErrI

func FoldRightErrI[I any, O any](initial O, fn func(int, O, I) (O, error), items ...I) (O, error)

func FoldRightI

func FoldRightI[I any, O any](initial O, fn func(int, O, I) O, items ...I) O
func Head[V any](items ...V) (V, bool)

func Join

func Join[T any](sep string, items ...T) string

func JoinErrFn

func JoinErrFn[T any](sep string, fn func(T) (string, error), items ...T) (string, error)

func JoinFn

func JoinFn[T any](sep string, fn func(T) string, items ...T) string

func Last

func Last[V any](vs ...V) (V, bool)

func Map

func Map[T any, U any](fn func(T) U, items ...T) []U

func MapErr

func MapErr[T any, U any](fn func(T) (U, error), items ...T) ([]U, error)

func MapErrI

func MapErrI[T any, U any](fn func(int, T) (U, error), items ...T) ([]U, error)

func MapI

func MapI[T any, U any](fn func(int, T) U, items ...T) []U

func MapPipe

func MapPipe[T any, U any](fns []func(T) U, items ...T) []U

func MapPipeErr

func MapPipeErr[T any, U any](fns []func(T) (U, error), items ...T) ([]U, error)

func MapPipeErrI

func MapPipeErrI[T any, U any](fns []func(int, T) (U, error), items ...T) ([]U, error)

func MapPipeI

func MapPipeI[T any, U any](fns []func(int, T) U, items ...T) []U

func Reduce

func Reduce[V any, A any](initial A, vs []V, fn func(V, A) A) A

func ReduceErr

func ReduceErr[V any, A any](vs []V, fn func(V, A) (A, error), s A) (A, error)

func Reverse

func Reverse[T any](items ...T) []T

func Sort

func Sort[T constraints.Ordered](items ...T) []T

func SortFn added in v1.0.29

func SortFn[T any, O constraints.Ordered](fn func(T) O, items ...T) []T

func Tail

func Tail[V any](items ...V) ([]V, bool)

func Times

func Times[V any, O any](v V, s int, fn func(V) O) []O

Types

type Pipe

type Pipe[T any] struct {
	// contains filtered or unexported fields
}

func NewPipe

func NewPipe[T any]() *Pipe[T]

func (*Pipe[T]) List

func (p *Pipe[T]) List(items ...T) []T

func (*Pipe[T]) Single

func (p *Pipe[T]) Single(item T) T

func (*Pipe[T]) Then

func (p *Pipe[T]) Then(fn func(T) T) *Pipe[T]

type PipeErr

type PipeErr[T any] struct {
	// contains filtered or unexported fields
}

func NewPipeErr

func NewPipeErr[T any]() *PipeErr[T]

func (*PipeErr[T]) List

func (p *PipeErr[T]) List(items ...T) ([]T, error)

func (*PipeErr[T]) Single

func (p *PipeErr[T]) Single(item T) (T, error)

func (*PipeErr[T]) Then

func (p *PipeErr[T]) Then(fn func(T) (T, error)) *PipeErr[T]

type Slicer added in v1.0.27

type Slicer[T any] []T

func (Slicer[T]) Append added in v1.0.27

func (t Slicer[T]) Append(items ...T)

func (Slicer[T]) Chunk added in v1.0.27

func (t Slicer[T]) Chunk(size int, items ...T) [][]T

func (Slicer[T]) FoldLeft added in v1.0.27

func (t Slicer[T]) FoldLeft(initial T, fn func(T, T) T, items ...T) T

func (Slicer[T]) FoldLeftErr added in v1.0.27

func (t Slicer[T]) FoldLeftErr(initial T, fn func(T, T) (T, error), items ...T) (T, error)

func (Slicer[T]) FoldLeftErrI added in v1.0.27

func (t Slicer[T]) FoldLeftErrI(initial T, fn func(int, T, T) (T, error), items ...T) (T, error)

func (Slicer[T]) FoldLeftI added in v1.0.27

func (t Slicer[T]) FoldLeftI(initial T, fn func(int, T, T) T, items ...T) T

func (Slicer[T]) FoldRight added in v1.0.27

func (t Slicer[T]) FoldRight(initial T, fn func(T, T) T, items ...T) T

func (Slicer[T]) FoldRightErr added in v1.0.27

func (t Slicer[T]) FoldRightErr(initial T, fn func(T, T) (T, error), items ...T) (T, error)

func (Slicer[T]) FoldRightErrI added in v1.0.27

func (t Slicer[T]) FoldRightErrI(initial T, fn func(int, T, T) (T, error), items ...T) (T, error)

func (Slicer[T]) FoldRightI added in v1.0.27

func (t Slicer[T]) FoldRightI(initial T, fn func(int, T, T) T, items ...T) T

func (Slicer[T]) Len added in v1.0.27

func (t Slicer[T]) Len() int

func (Slicer[T]) Map added in v1.0.27

func (t Slicer[T]) Map(fn func(T) T) []T

func (Slicer[T]) MapErr added in v1.0.27

func (t Slicer[T]) MapErr(fn func(T) (T, error)) ([]T, error)

func (Slicer[T]) MapErrI added in v1.0.27

func (t Slicer[T]) MapErrI(fn func(int, T) (T, error)) ([]T, error)

func (Slicer[T]) MapI added in v1.0.27

func (t Slicer[T]) MapI(fn func(int, T) T) []T

Jump to

Keyboard shortcuts

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