slice

package module
v0.0.10 Latest Latest
Warning

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

Go to latest
Published: Apr 22, 2024 License: MIT Imports: 9 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FromPattern

func FromPattern[T any](pat string, inp []T) (res []T, err error)

func Parse added in v0.0.10

func Parse(pat string) (unixT, off int64)

func ParsePattern added in v0.0.10

func ParsePattern(pat string, max int) (from, to int, err error)

func ParseTimeSlice added in v0.0.10

func ParseTimeSlice(pat string) (from, to int64, err error)

can be provided {from date}:{to date} also accepts y{value} m{value} d{value} to specify just year, month, day, or some combination of them. if a [y|m|d] expression has "-" precedengin it, it is instead deducted from the current time. t[-y1:] would mean "in the last year until now" t[-2m:-1m] would mean "during the time between 60 and 30 days ago"

func ShiftLeft

func ShiftLeft[T any](arg string, arr []T) (res []T, err error)

func ShiftRight

func ShiftRight[T any](arg string, arr []T) (res []T, err error)

func Slice

func Slice[T any](from, to, l int, inp []T) (res []T)

func SplitWithAll

func SplitWithAll(str string, match ...string) (res []string)

Types

type Act

type Act[T any] func(pat string, arr []T) (res []T, err error)

type Expression

type Expression[T any] struct {
	Syntax map[string]Act[T]
	// contains filtered or unexported fields
}

func NewExpression

func NewExpression[T any]() *Expression[T]

func (*Expression[T]) Eval

func (e *Expression[T]) Eval(arr []T) (res []T, err error)

func (*Expression[T]) Find

func (e *Expression[T]) Find(pat string) (Act[T], bool)

func (*Expression[T]) Parse

func (e *Expression[T]) Parse(pat string)

Jump to

Keyboard shortcuts

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