Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/jacalz/eval
Minimalistic evaluator for mathematical expressions.
https://github.com/jacalz/eval
golang hacktoberfest math shunting-yard-algorithm
Last synced: about 2 months ago
JSON representation
Minimalistic evaluator for mathematical expressions.
- Host: GitHub
- URL: https://github.com/jacalz/eval
- Owner: Jacalz
- License: bsd-3-clause
- Created: 2021-07-18T19:11:47.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2024-10-26T22:58:57.000Z (about 2 months ago)
- Last Synced: 2024-10-27T00:05:31.053Z (about 2 months ago)
- Topics: golang, hacktoberfest, math, shunting-yard-algorithm
- Language: Go
- Homepage:
- Size: 1.07 MB
- Stars: 2
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# eval
A minimalistic math parser for Go. It implements the [shunting-yard-algorithm](https://brilliant.org/wiki/shunting-yard-algorithm/)
and allows to parse math from strings.## Work in progress
The current implementation requires spaces between each math token and does not support trigionometric functions yet.## Example
The library can be used as illustrated below:```go
package mainimport (
"fmt""github.com/jacalz/eval"
)func main() {
input := "( 6 - 2 * ( 6 / 3 ) ) ^ 3"
result, err := eval.Evaluate(input)
if err != nil {
panic(err)
}fmt.Println(result)
}
```A more elaborate example can be found in the `example` folder.