Popularity
5.2
Growing
Activity
0.0
Stable
45
2
11

Monthly Downloads: 5,256
Programming language: Elixir
License: MIT License
Tags: Text And Numbers    

abacus alternatives and similar packages

Based on the "Text and Numbers" category.
Alternatively, view abacus alternatives based on common mentions on social networks and blogs.

Do you think we are missing an alternative of abacus or a related project?

Add another 'Text and Numbers' Package

README

Abacus Build status

A parser for mathematical expressions.

https://hex.pm/packages/abacus

Usage

Abacus.eval(expression, scope)

Parses and evaluates the given expression. Variables can be supplied as a map of binaries in the scope.

Examples

iex> Abacus.eval("1 + 1")
{:ok, 2}
iex> Abacus.eval("sin(floor(3 + 2.5)) / 3")
{:ok, -0.3196414248877128}
iex> Abacus.eval("a * b", %{"a" => 10, "b" => 10})
{:ok, 100}

Abacus.parse(expression)

Parses the expression and returns the syntax tree.

Features

An incomplete list of supported and planned features

  • [x] basic operators (+, -, *, /, ^)
  • [x] factorial (!)
  • [x] bitwise operators (|, &, >>, <<, ~, |^ (xor))
  • [x] support for functions
    • [x] trigonometric functions(sin, cos, tan)
    • [x] floating point manipulation(ceil, floor, round)
  • [x] support for variables
  • [ ] support for parsing units
  • [ ] support for converting units

Installation

  1. Add abacus to your list of dependencies in mix.exs:

    def deps do
      [{:abacus, "~> 0.4.2"}]
    end
    
  2. Ensure abacus is started before your application:

    def application do
      [applications: [:abacus]]
    end