Math Expression Parser | Solve Any Mathematical Expression

A Short Background Story
I have been using Kodular for more than 3 years now. It has helped me a lot to clear my concepts regarding programming. It has also motivated me to learn java. Recently I started learning java and to implement what I learn in java I started making simple extensions so I could practice what I learn and don’t get bored.Special thanks to @Atom_Developer for helping me out whenever I am struck at something and being the motivation for me and many others.And also to this amazing platform :kodular:


Expression Parser
I have made this pretty simple but powerful extension that can parse a mathematical expression and instantly return result to you.The extension is made using a powerful library called mXParser. But note that this extension is already provided by taifun here. I just made it for learning purpose and nothing more.

Example of expression :
You can find area of sphere by using
4 * pi * r^2
Where pi is a constant already available in the library and r is the radius that you get as an input from user.


Images of Blocks

  • Parse Block

pa*rse block
This is the main block of extension. This will be used to parse expressions and get result instantly. Moreover all other blocks are also meant to be used with this block to get result.

  • Simple Formula Blocks
    Formula Blocks
    These block return an expression with your provided parameters. Use these blocks with parse block to get result.
  • Constant Blocks
    constant blocks
    The block GetConstants returns a list of constants that are in the library. The second blocks provides detail of all the constants that are returned from GetConstants block.
  • Error Occurred Block
    error block
    This event block is triggered when there is an error in your expression. You can find error details through error parameter of this block

Download AIX File
com.dreamers.ExpressionParser.aix (630.2 KB)


How to make expression for a formula
I have provided some basic formula blocks to help you understand the working of extension. You can easily create expression for any formula like I have shown above.Lets have another example:
You can find Square root of any number by using:
"sqrt(number)"
here sqrt represents square root and number can be any number like 1,2,3,4etc.
You can find more details on mXparser.

The uses of this extension are unlimited. You can use logic gates like && , || , ! etc. You can make comparisons like =, <, > etc. You have a large number of constants that you can get by using a single block. You can find value of those constants by parsing them using the parse block. You can use cos, tan, sin etc. You can easily make a calculator by using this extension and much more.


Hope you guys enjoy it and find this extension useful. Make sure to check it and let me know what you think. Happy Koding :kodular:

13 Likes

Congratulations for your first extension @zainulhassan!
And a very nice try as a beginner :+1:t2: :grin: .

2 Likes

Congratulations for your extension

2 Likes

Congrats @zainulhassan

2 Likes

Great Extension. :grinning:
Congrats :man_dancing:t2: :man_dancing:t2:

2 Likes

helo please help me i need code kodular like this
Multiply : 2(44) x2
Result : *24 *42 *44 *22…
Multiply : 2(444) x3
Result : *242 *422 *442 *222 *444 *424 *224…

My math teacher used to call me a dumb machanism! :stuck_out_tongue_winking_eye: Can you please elaborate what you exactly looking for?

Lottery please help me!!
Capture


This is my apk in Kodular but it’s doesn’t has code