Math expression parser and evaluator
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
config
lib
src
test
.formatter.exs
.gitignore
.travis.yml
LICENSE
README.md
coveralls.json
mix.exs
mix.lock

README.md

Leibniz

Build Status codecov

Leibniz is a pure erlang/elixir math expression parser and evaluator.

Installation

defp deps() do
  [{:leibniz, "~> 1.0.0"}]
end

Usage

Documentation

Leibniz provides two core functionalities, evaluating valid math expressions and evaluating valid math expression in a given context.

Examples

Evaluating simple math expressions

Leibniz.eval("1 + 1")

{:ok, 2}

Evaluating math expressions in a given context

Leibniz.eval("10 * foo", foo: 10)

{:ok, 100}
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