eval

package
v0.0.0-...-5948a14 Latest Latest
Warning

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

Go to latest
Published: Jul 26, 2020 License: CC0-1.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Format

func Format(e Expr) string

Format an expression as a string

Types

type Env

type Env map[Var]float64

Env represents an variable environment map

type Expr

type Expr interface {
	Eval(env Env) float64
	Check(vars map[Var]bool) error
	String() string
}

Expr is an arithmetic expression

func Parse

func Parse(input string) (_ Expr, err error)

Parse expressions and evaluate them

type Var

type Var string

Var identifies a variable, e.g x, y

func (Var) Check

func (v Var) Check(vars map[Var]bool) error

Check whether a var is correct

func (Var) Eval

func (v Var) Eval(env Env) float64

Eval statifies the Expr interface for Var

func (Var) String

func (v Var) String() string

Jump to

Keyboard shortcuts

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