coreiter

package
v0.0.0-...-2561dba Latest Latest
Warning

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

Go to latest
Published: Dec 15, 2024 License: GPL-3.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// FilterFuncName is the name this function is registered as.
	FilterFuncName = "filter"
)
View Source
const (
	// MapFuncName is the name this function is registered as.
	MapFuncName = "map"
)
View Source
const (
	// ModuleName is the prefix given to all the functions in this module.
	ModuleName = "iter"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type FilterFunc

type FilterFunc struct {
	Type *types.Type // this is the type of the elements in our input list
	// contains filtered or unexported fields
}

FilterFunc is the standard filter iterator function that runs a function on each element in a list. That function must return true to keep the element, or false otherwise. The function then returns a list with the subset of kept elements from the input list. This implements the signature: `func(inputs []?1, function func(?1) bool) []?1` instead of the alternate with the two input args swapped, because while the latter is more common with languages that support partial function application, the former variant that we implemented is much more readable when using an inline lambda.

func (*FilterFunc) ArgGen

func (obj *FilterFunc) ArgGen(index int) (string, error)

ArgGen returns the Nth arg name for this function.

func (*FilterFunc) Build

func (obj *FilterFunc) Build(typ *types.Type) (*types.Type, error)

Build is run to turn the polymorphic, undetermined function, into the specific statically typed version. It is usually run after Unify completes, and must be run before Info() and any of the other Func interface methods are used. This function is idempotent, as long as the arg isn't changed between runs.

func (*FilterFunc) Info

func (obj *FilterFunc) Info() *interfaces.Info

Info returns some static info about itself. Build must be called before this will return correct data.

func (*FilterFunc) Init

func (obj *FilterFunc) Init(init *interfaces.Init) error

Init runs some startup code for this function.

func (*FilterFunc) Stream

func (obj *FilterFunc) Stream(ctx context.Context) error

Stream returns the changing values that this func has over time.

func (*FilterFunc) String

func (obj *FilterFunc) String() string

String returns a simple name for this function. This is needed so this struct can satisfy the pgraph.Vertex interface.

func (*FilterFunc) Validate

func (obj *FilterFunc) Validate() error

Validate tells us if the input struct takes a valid form.

type MapFunc

type MapFunc struct {
	Type  *types.Type // this is the type of the elements in our input list
	RType *types.Type // this is the type of the elements in our output list
	// contains filtered or unexported fields
}

MapFunc is the standard map iterator function that applies a function to each element in a list. It returns a list with the same number of elements as the input list. There is no requirement that the element output type be the same as the input element type. This implements the signature: `func(inputs []?1, function func(?1) ?2) []?2` instead of the alternate with the two input args swapped, because while the latter is more common with languages that support partial function application, the former variant that we implemented is much more readable when using an inline lambda. TODO: should we extend this to support iterating over map's and structs, or should that be a different function? I think a different function is best.

func (*MapFunc) ArgGen

func (obj *MapFunc) ArgGen(index int) (string, error)

ArgGen returns the Nth arg name for this function.

func (*MapFunc) Build

func (obj *MapFunc) Build(typ *types.Type) (*types.Type, error)

Build is run to turn the polymorphic, undetermined function, into the specific statically typed version. It is usually run after Unify completes, and must be run before Info() and any of the other Func interface methods are used. This function is idempotent, as long as the arg isn't changed between runs.

func (*MapFunc) Info

func (obj *MapFunc) Info() *interfaces.Info

Info returns some static info about itself. Build must be called before this will return correct data.

func (*MapFunc) Init

func (obj *MapFunc) Init(init *interfaces.Init) error

Init runs some startup code for this function.

func (*MapFunc) Stream

func (obj *MapFunc) Stream(ctx context.Context) error

Stream returns the changing values that this func has over time.

func (*MapFunc) String

func (obj *MapFunc) String() string

String returns a simple name for this function. This is needed so this struct can satisfy the pgraph.Vertex interface.

func (*MapFunc) Validate

func (obj *MapFunc) Validate() error

Validate tells us if the input struct takes a valid form.

Jump to

Keyboard shortcuts

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