aboutsummaryrefslogtreecommitdiff
path: root/README.md
blob: 289d811bafa3b0da31bb68fbff7af71bd4446545 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
# GoMathExecutor [![GoDoc](https://godoc.org/github.com/neonxp/GoMathExecutor?status.svg)](https://godoc.org/github.com/neonxp/GoMathExecutor) [![Build Status](https://travis-ci.org/neonxp/GoMathExecutor.svg?branch=master)](https://travis-ci.org/neonxp/GoMathExecutor)

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
```