saulecabrera / leibniz

Math expression parser and evaluator

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

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

About

Math expression parser and evaluator

License:MIT License


Languages

Language:Erlang 81.5%Language:Elixir 18.5%