Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/saulecabrera/leibniz
Math expression parser and evaluator
https://github.com/saulecabrera/leibniz
evaluator math-expression-parser
Last synced: 9 days 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 (over 6 years ago)
- Default Branch: master
- Last Pushed: 2018-05-06T14:30:54.000Z (over 6 years ago)
- Last Synced: 2024-10-13T14:50:44.863Z (24 days ago)
- Topics: evaluator, math-expression-parser
- Language: Erlang
- Size: 20.5 KB
- Stars: 22
- Watchers: 3
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Leibniz
[![Build Status](https://travis-ci.org/saulecabrera/leibniz.svg?branch=master)](https://travis-ci.org/saulecabrera/leibniz)
[![codecov](https://codecov.io/gh/saulecabrera/leibniz/branch/master/graph/badge.svg)](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