Skip to content

Latest commit

 

History

History
41 lines (29 loc) · 1.16 KB

README.md

File metadata and controls

41 lines (29 loc) · 1.16 KB

Build Status wercker status

gostr

DESCRIPTION

Gostr is a evaluator for a mathematical and logical expressions that allows run-time binding of values to variables referenced in the formulas.

EXAMPLE

This is probably simplest to illustrate in code:

values := make(map[string]interface{})
values["a"] = 5
result := gostr.Evaluate("a * 2", values)
fmt.Println("Result:", result)
#=> Result: 10

result := gostr.Evaluate("a + 3 * 2", values)
fmt.Println("Result:", result)
#=> Result: 11

result := gostr.Evaluate("(a + 3) * 2", values)
fmt.Println("Result:", result)
#=> Result: 16

I have added some simple examples. Run example.go to check those.

BUILT-IN OPERATORS AND FUNCTIONS

Math: + - * /

Logic: < > <= >= <> != = AND OR

Functions: ISBLANK LENGTH NOT ROUND