Giter Site home page Giter Site logo

mtellis2 / math-expression-parser Goto Github PK

View Code? Open in Web Editor NEW

This project forked from facaiy/math-expression-parser

0.0 1.0 0.0 54 KB

A scala library for parsing mathemitical expressions with support for parentheses and variables.

License: MIT License

Scala 100.00%

math-expression-parser's Introduction

math-expression-parser

A scala library for parsing mathemitical expressions with support for parentheses and variables.

features:

  • math operators: +, -, *, /, **(power)
  • parentheses ( ) and comma ,
  • all function of scala.math, except of random, E and PI
  • variable name: $ with valid Java variable name

Install

  1. maven
    <dependency>
      <groupId>io.github.facaiy</groupId>
      <artifactId>math-expression-parser</artifactId>
      <version>0.0.2</version>
    </dependency>
    

Usage

A simple example:

import io.github.facaiy.math.expression.MathExp

val str = "1.0 + sqrt(2 * $a1) + $a2 ** 2"
val ex = MathExp.parse(str)

val variables = Map("a1" -> 2, "a2" -> 1)
val output = ex.eval(variables)
// output = 4.0

val output1 = ex.eval(Map("a1" -> 8.0, "a2" -> 2))
// output1 = 9.0

Release

# Ref: https://central.sonatype.org/pages/apache-maven.html
mvn release:clean release:prepare
mvn release:perform

math-expression-parser's People

Contributors

benjaminjacobberg avatar facaiy avatar upx86 avatar vbachurin avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.