closure_values

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: 2 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)

func VarInt0

func VarInt0(env *Env) int

Types

type Env

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

func NewEnv

func NewEnv(outer *Env) *Env

type Func

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

type FuncInt

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

func DeclCollatz

func DeclCollatz(env *Env, idx int) FuncInt
  interpreted version of:

	func collatz(n int) {
		for n > 1 {
			if n&1 != 0 {
				n = ((n * 3) + 1) / 2
			} else {
				n = n / 2
			}
		}
	}

func DeclFibonacci

func DeclFibonacci(env *Env, idx int) 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, idx int) 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 {
	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(idx int, 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(upn, idx int) X

func VarIncInt

func VarIncInt(idx int) X

func VarSetInt

func VarSetInt(idx int, 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

func NoteqIntInt

func NoteqIntInt(lhs, rhs XInt) XBool

type XFunc

type XFunc func(env *Env) Func

type XFuncInt

type XFuncInt func(env *Env) FuncInt

func DeclFuncInt

func DeclFuncInt(idx int, paramTypes []r.Type, body X) XFuncInt

func MakeFuncInt

func MakeFuncInt(paramTypes []r.Type, body X) XFuncInt

type XInt

type XInt func(*Env) int

func AddIntInt

func AddIntInt(lhs, rhs XInt) XInt

func BitandIntInt

func BitandIntInt(lhs, rhs XInt) XInt

func CallInt

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

func Int

func Int(n int) XInt

func MulIntInt

func MulIntInt(lhs, rhs XInt) XInt

func RshiftIntInt

func RshiftIntInt(lhs, rhs XInt) XInt

func SubIntInt

func SubIntInt(lhs, rhs XInt) XInt

func VarInt

func VarInt(idx int) XInt

Jump to

Keyboard shortcuts

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