closure_maps

package
v0.0.0-...-2ff796e Latest Latest
Warning

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

Go to latest
Published: May 6, 2024 License: MPL-2.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Nop

func Nop(env *Env) (r.Value, []r.Value)

Types

type Env

type Env struct {
	Binds map[string]r.Value
	Outer *Env
}

func NewEnv

func NewEnv(outer *Env) *Env

func (*Env) DefineFunc

func (env *Env) DefineFunc(name string, t r.Type, value r.Value) r.Value

func (*Env) DefineVar

func (env *Env) DefineVar(name string, t r.Type, value r.Value) r.Value

type Func

type Func func(args ...r.Value) (r.Value, []r.Value)

type FuncInt

type FuncInt func(args ...r.Value) int

func DeclFibonacci

func DeclFibonacci(env *Env, funcName string) FuncInt
  interpreted version of:

	func fibonacci(n int) int {
		if (n <= 2) {
			return 1
		}
		return fibonacci(n-1) + fibonacci(n-2)
	}

func DeclSum

func DeclSum(env *Env, funcName string) FuncInt
  interpreted version of:

	func sum(n int) int {
		total := 0
		for i := 1; i <= n; i++ {
			total += i
		}
		return total
	}

type SParam

type SParam struct {
	Name string
	Type r.Type
}

type SReturn

type SReturn struct {
	// contains filtered or unexported fields
}

type X

type X func(*Env) (r.Value, []r.Value)

func Block

func Block(list ...X) X

func Const

func Const(value interface{}) X

func DeclVar

func DeclVar(name string, expr X) X

func For

func For(init X, pred XBool, post X, body X) X

func If

func If(pred XBool, then, els X) X

func IntToX

func IntToX(f XInt) X

func Return

func Return(exprs ...X) X

func ReturnInt

func ReturnInt(expr XInt) X

func Var

func Var(name string) X

func VarIncInt

func VarIncInt(name string) X

func VarSetInt

func VarSetInt(name string, expr XInt) X

type X1

type X1 func(*Env) r.Value

type XBool

type XBool func(*Env) bool

func LessIntInt

func LessIntInt(lhs, rhs XInt) XBool

func LesseqIntInt

func LesseqIntInt(lhs, rhs XInt) XBool

type XFunc

type XFunc func(env *Env) Func

type XFuncInt

type XFuncInt func(env *Env) FuncInt

func DeclFuncInt

func DeclFuncInt(name string, params []SParam, body X) XFuncInt

func MakeFuncInt

func MakeFuncInt(name string, params []SParam, body X) XFuncInt

type XInt

type XInt func(*Env) int

func AddIntInt

func AddIntInt(lhs, rhs XInt) XInt

func CallInt

func CallInt(fun X, args ...X) XInt

func Int

func Int(n int) XInt

func SubIntInt

func SubIntInt(lhs, rhs XInt) XInt

func VarInt

func VarInt(name string) XInt

Jump to

Keyboard shortcuts

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