callable

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: May 31, 2023 License: EUPL-1.2 Imports: 6 Imported by: 1

Documentation

Overview

Package callable provides syntaxes and builtins to work with callables / functions / procedure.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Apply

func Apply(eng *eval.Engine, env sxpf.Environment, args []sxpf.Object) (sxpf.Object, error)

Apply calls the given function with the given arguments.

func CallableP

func CallableP(args []sxpf.Object) (sxpf.Object, error)

CallableP returns True, if the given argument is a callable.

func Fold

func Fold(eng *eval.Engine, env sxpf.Environment, args []sxpf.Object) (sxpf.Object, error)

Fold will apply the given function pairwise to list of args.

func FoldReverse

func FoldReverse(eng *eval.Engine, env sxpf.Environment, args []sxpf.Object) (sxpf.Object, error)

FoldReverse will apply the given function reversed pairwise to reversed list of args.

func GetParameterSymbol

func GetParameterSymbol(params []*sxpf.Symbol, obj sxpf.Object) (*sxpf.Symbol, error)

func LambdaS

func LambdaS(eng *eval.Engine, env sxpf.Environment, args *sxpf.List) (eval.Expr, error)

LambdaS parses a procedure specification.

func Map

func Map(eng *eval.Engine, env sxpf.Environment, args []sxpf.Object) (sxpf.Object, error)

Map returns a list, where all member are the result of the given function to all original list members.

func ParseProcedure

func ParseProcedure(eng *eval.Engine, env sxpf.Environment, name string, paramSpec, bodySpec sxpf.Object) (eval.Expr, error)

ParseProcedure parses a procedure definition, where some parsing is already done.

Types

type LambdaExpr

type LambdaExpr struct {
	Name   string
	Params []*sxpf.Symbol
	Rest   *sxpf.Symbol
	Front  []eval.Expr // all expressions, but the last
	Last   eval.Expr
}

func (*LambdaExpr) Compute

func (le *LambdaExpr) Compute(eng *eval.Engine, env sxpf.Environment) (sxpf.Object, error)

type Procedure

type Procedure struct {
	Env    sxpf.Environment
	Name   string
	Params []*sxpf.Symbol
	Rest   *sxpf.Symbol
	Front  []eval.Expr // all expressions, but the last
	Last   eval.Expr
}

Procedure represents the procedure definition form (aka lambda).

func (*Procedure) Call

func (p *Procedure) Call(eng *eval.Engine, _ sxpf.Environment, args []sxpf.Object) (sxpf.Object, error)

func (*Procedure) IsAtom

func (p *Procedure) IsAtom() bool

func (*Procedure) IsEql

func (p *Procedure) IsEql(other sxpf.Object) bool

func (*Procedure) IsEqual

func (p *Procedure) IsEqual(other sxpf.Object) bool

func (*Procedure) IsNil

func (p *Procedure) IsNil() bool

func (*Procedure) Print

func (p *Procedure) Print(w io.Writer) (int, error)

func (*Procedure) Repr

func (p *Procedure) Repr() string

func (*Procedure) String

func (p *Procedure) String() string

Jump to

Keyboard shortcuts

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