Package GoMathExecutor provides simple expression executor
Find a file
Alexander Kiryukhin c07ece7c51 Fix crit
2020-02-13 23:15:50 +03:00
.vscode initial commit 2020-02-13 22:55:13 +03:00
examples initial commit 2020-02-13 22:55:13 +03:00
.codecov.yml initial commit 2020-02-13 22:55:13 +03:00
.travis.yml initial commit 2020-02-13 22:55:13 +03:00
calculator.go initial commit 2020-02-13 22:55:13 +03:00
calculator_test.go initial commit 2020-02-13 22:55:13 +03:00
checklicense.sh initial commit 2020-02-13 22:55:13 +03:00
defaults.go initial commit 2020-02-13 22:55:13 +03:00
doc.go Fix crit 2020-02-13 23:15:50 +03:00
function.go initial commit 2020-02-13 22:55:13 +03:00
go.mod initial commit 2020-02-13 22:55:13 +03:00
LICENSE initial commit 2020-02-13 22:55:13 +03:00
Makefile fix makefile 2020-02-13 23:14:11 +03:00
operator.go initial commit 2020-02-13 22:55:13 +03:00
README.md Codecov 2020-02-13 23:11:13 +03:00
tokenizer.go initial commit 2020-02-13 22:55:13 +03:00
tokenizer_test.go initial commit 2020-02-13 22:55:13 +03:00
types.go initial commit 2020-02-13 22:55:13 +03:00

GoMathExecutor GoDoc Build Status codecov

Package GoMathExecutor provides simple expression executor.

Installation

go get github.com/neonxp/GoMathExecutor

Usage

calc := executor.NewCalc()
calc.AddOperators(executor.MathOperators) // Loads default MathOperators (see: defaults.go)
calc.Prepare("2+2*2") // Prepare expression
calc.Execute(nil) // == 6, nil
calc.Prepare("x * (y+z)") // Prepare another expression with variables
calc.Execute(map[string]float64{
	"x": 3,
	"y": 2,
	"z": 1,
}) // == 9, nil