leibniz v1.0.0 Leibniz

Leibniz is a math expression parser and evaluator.

Link to this section Summary

Functions

Evaluates a valid math expression interpolating any given values

Link to this section Functions

Link to this function eval(expr, vars \\ [])
eval(String.t(), Keyword.t(number())) :: {:ok, number()} | {:error, term()}

Evaluates a valid math expression interpolating any given values.

Examples

iex> Leibniz.eval("2 * 10 / 2")
{:ok, 10.0}

iex> Leibniz.eval("2 * foo + bar - baz", foo: 5.3, bar: 10, baz: 3)
{:ok, 17.6}

iex> Leibniz.eval("2 * x + y")
{:error, "value expected for the following dependencies: x,y"}