Documentation ¶
Index ¶
- Constants
- Variables
- func AsCDF(expr Expression) (cdflib.CDF, error)
- func AsDifferentiable(expr Expression) (cdflib.DifferentiableCDF, error)
- func AsFloat(expr Expression) (float64, error)
- func AsInt(expr Expression) (int, error)
- func IsFloat(expr Expression) bool
- func TypeName(t ExpressionType) string
- type Color
- type Environment
- type Expression
- func Add(a Expression, b Expression) Expression
- func Apply(name Expression, args []Expression) Expression
- func Assign(name string, e Expression) Expression
- func Brian() Expression
- func Div(a Expression, b Expression) Expression
- func Float(v float64) Expression
- func Lookup(name string) Expression
- func Mult(a Expression, b Expression) Expression
- func Negate(expr Expression) Expression
- func Parse(code string) ([]Expression, error)
- func Plot(fn string, args []PlotArg) Expression
- func PlotNoArgs(fn string) Expression
- func Sub(a Expression, b Expression) Expression
- func Void() Expression
- type ExpressionType
- type Interpreter
- type MimeData
- type PlotArg
Constants ¶
View Source
const ( DefaultFillAlpha = 0.8 DefaultWidth = 800 DefaultHeight = 600 )
View Source
const ADD_ASSIGN = 57375
View Source
const ADD_OP = 57366
View Source
const AND_OP = 57361
View Source
const ASSIGN_OP = 57365
View Source
const BREAK = 57351
View Source
const BRIAN = 57350
View Source
const COLOR = 57347
View Source
const COMMA = 57352
View Source
const DIV_ASSIGN = 57378
View Source
const DIV_OP = 57369
View Source
const ELSE = 57364
View Source
const EQ_OP = 57355
View Source
const GE_OP = 57360
View Source
const GT_OP = 57359
View Source
const IDENTIFIER = 57348
View Source
const IF = 57363
View Source
const LEFT_ASSIGN = 57373
View Source
const LEFT_OP = 57371
View Source
const LE_OP = 57358
View Source
const LPAREN = 57353
View Source
const LT_OP = 57357
View Source
const MOD_ASSIGN = 57379
View Source
const MOD_OP = 57370
View Source
const MULT_ASSIGN = 57377
View Source
const MULT_OP = 57368
View Source
const NE_OP = 57356
View Source
const NUM = 57346
View Source
const OR_OP = 57362
View Source
const PLOT = 57349
View Source
const RIGHT_ASSIGN = 57374
View Source
const RIGHT_OP = 57372
View Source
const RPAREN = 57354
View Source
const SUB_ASSIGN = 57376
View Source
const SUB_OP = 57367
Variables ¶
View Source
var ( // From https://en.wikipedia.org/wiki/Web_colors NamedColors = map[string]*color.RGBA{ "white": &color.RGBA{0xFF, 0xFF, 0xFF, 0xFF}, "silver": &color.RGBA{0xC0, 0xC0, 0xC0, 0xFF}, "gray": &color.RGBA{0x80, 0x80, 0x80, 0xFF}, "black": &color.RGBA{0x00, 0x00, 0x00, 0xFF}, "red": &color.RGBA{0xFF, 0x00, 0x00, 0xFF}, "maroon": &color.RGBA{0x80, 0x00, 0x00, 0xFF}, "yellow": &color.RGBA{0xFF, 0xFF, 0x00, 0xFF}, "olive": &color.RGBA{0x80, 0x80, 0x00, 0xFF}, "lime": &color.RGBA{0x00, 0xFF, 0x00, 0xFF}, "green": &color.RGBA{0x00, 0x80, 0x00, 0xFF}, "aqua": &color.RGBA{0x00, 0xFF, 0xFF, 0xFF}, "teal": &color.RGBA{0x00, 0x80, 0x80, 0xFF}, "blue": &color.RGBA{0x00, 0x00, 0xFF, 0xFF}, "navy": &color.RGBA{0x00, 0x00, 0x80, 0xFF}, "fuchsia": &color.RGBA{0xFF, 0x00, 0xFF, 0xFF}, "purple": &color.RGBA{0x80, 0x00, 0x80, 0xFF}, } PositionColors = []string{ "blue", "red", "green", "yellow", "purple", "teal", "silver", "maroon", } )
Functions ¶
func AsDifferentiable ¶
func AsDifferentiable(expr Expression) (cdflib.DifferentiableCDF, error)
func AsFloat ¶
func AsFloat(expr Expression) (float64, error)
func AsInt ¶
func AsInt(expr Expression) (int, error)
func IsFloat ¶
func IsFloat(expr Expression) bool
func TypeName ¶
func TypeName(t ExpressionType) string
Types ¶
type Color ¶
func ColorByName ¶
func ColorByPosition ¶
func ColorByPosition() Color
func ColorBySpec ¶
type Environment ¶
type Environment interface { Out() io.Writer Err() io.Writer GetVar(name string) (Expression, bool) SetVar(name string, expr Expression) }
type Expression ¶
type Expression interface { Type() ExpressionType Eval(env Environment) (Expression, error) MimeData() MimeData String() string }
func Add ¶
func Add(a Expression, b Expression) Expression
func Apply ¶
func Apply(name Expression, args []Expression) Expression
func Assign ¶
func Assign(name string, e Expression) Expression
func Brian ¶
func Brian() Expression
func Div ¶
func Div(a Expression, b Expression) Expression
func Float ¶
func Float(v float64) Expression
func Lookup ¶
func Lookup(name string) Expression
func Mult ¶
func Mult(a Expression, b Expression) Expression
func Negate ¶
func Negate(expr Expression) Expression
func Parse ¶
func Parse(code string) ([]Expression, error)
func Plot ¶
func Plot(fn string, args []PlotArg) Expression
func PlotNoArgs ¶
func PlotNoArgs(fn string) Expression
func Sub ¶
func Sub(a Expression, b Expression) Expression
func Void ¶
func Void() Expression
type ExpressionType ¶
type ExpressionType int
const ( VOID ExpressionType = iota SYMBOL ANY FLOAT IMAGE CDF DISCRETE DIFFERENTIABLE PROBABILITY LAMBDA )
type Interpreter ¶
type Interpreter interface { SetOut(out io.Writer) io.Writer SetErr(err io.Writer) io.Writer Eval(code string) (Expression, error) }
func MakeInterpreter ¶
func MakeInterpreter() Interpreter
type PlotArg ¶
type PlotArg struct { Value Expression Color Color FillAlpha float64 }
Click to show internal directories.
Click to hide internal directories.