ExprCal | Library

Tech Stack :
Organisation Logo

A compact library for compiling and solving complex mathematical expressions (still under tests). A String expression is brought into Object Model for better processing & greater readability.

This library was developed in my college days so pardon me if I miss following any conventions.

Render an expression

Features

Every Expression type object has ExpressionFramgment objects in it stored into a hash-map.

Types of ExpressionFramgments:-

  • Number
  • Function
  • Expression
  • Constant
  • Operator
  • Sign
  • Bracket

Expression types that are accepted:

  • [(Number*)(Function*)(Constant*)] - [(Number*)[//*](Function*)[//*](Constant*)] (represented in regex)
  • [(Number+|Function+|Constant+)Operator(Number+|Function+|Constant+)] (represented in regex)
  • Number String [1.233.999.00.33] - 1.233 * 0.999 * 0.00 * 0.33
  • Function inside Function i.e. f(g(X)) is accepted.
  • Fragments with spaces can also be written for better expression readability.
  • Number,Function,Expression,Constant fragments with multiple Sign fragments are accepted.

Constant Pool:

Constants follow Uppercase paradigm. So always declare Constants in UpperCase to avoid error.

Types of Constant declarations:-

  • "X" means X=0
  • "X=" means X=0
  • "X=10" means X=10.0
  • "X=0.0" means X=0.0
  • "X=3*4+sqrt(9)" means X=15.0
  • "X=A" means X=A=some pre-declared value

Function Pool:

static methods of any class can be inserted in the Function Pool. The first parameter should be the name with which it will be known in the pool & second should be the method itself.

But Functions follow some rules:-

  • Functions follow Lowercase paradigm. So always declare Functions in Lowercase to avoid error.
  • The parameters passed should be Numbers
  • The return type of the Functions should be Number

Method Chaining:

Method chaining has been introduced for some functions invoked via an 'ExpressionRenderer' object.

Warning:

  • Functions and Constants must be declared before setting the expression.
  • Don't declare Constants together. viz:- don't write "PIX" write "PI*X"

RH

Made with ❤️ by Rupanjan
Cookie Settings
Copyright © 2021 Rupanjan Hari