https://github.com/saulecabrera/leibniz
Math expression parser and evaluator
https://github.com/saulecabrera/leibniz
evaluator math-expression-parser
Last synced: about 1 year ago
JSON representation
Math expression parser and evaluator
- Host: GitHub
- URL: https://github.com/saulecabrera/leibniz
- Owner: saulecabrera
- License: mit
- Created: 2018-04-02T00:58:33.000Z (about 8 years ago)
- Default Branch: master
- Last Pushed: 2018-05-06T14:30:54.000Z (about 8 years ago)
- Last Synced: 2025-03-18T09:11:27.675Z (about 1 year ago)
- Topics: evaluator, math-expression-parser
- Language: Erlang
- Size: 20.5 KB
- Stars: 22
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Leibniz
[](https://travis-ci.org/saulecabrera/leibniz)
[](https://codecov.io/gh/saulecabrera/leibniz)
Leibniz is a pure erlang/elixir math expression parser and evaluator.
## Installation
```elixir
defp deps() do
[{:leibniz, "~> 1.0.0"}]
end
```
## Usage
[Documentation](https://hexdocs.pm/leibniz/api-reference.html)
Leibniz provides two core functionalities, evaluating valid math expressions and evaluating valid math expression in a given context.
#### Examples
Evaluating simple math expressions
```elixir
Leibniz.eval("1 + 1")
{:ok, 2}
```
Evaluating math expressions in a given context
```elixir
Leibniz.eval("10 * foo", foo: 10)
{:ok, 100}
```
```elixir
Leibniz.eval("1 * baz")
{:error, "value expected for the following dependencies: baz"}
```
## TODO
- [ ] Improve errors
- [ ] Provide a `parse/1` function
- [ ] Provide a `depencies/1` function
- [ ] Add trigonometric and other math functions
## LICENSE
MIT