Math.js How to Evaluate Expressions

I’m curious if anyone has tried advanced features using the math.js API call. I’ve only had success with simple functions, but I would love to build out an API call that goes something like this:
{
“expr”: “if {{pre.year_calc.result}}=-1
return({{ursp.MSRP}}1.005)
if {{pre.year_calc.result}}=0
return({{ursp.MSRP}}.96.005)
// Continue pattern 15 more times//”
}
Is this possible @arnav/@vinit? It would sure save me a ton of extra gambits if so. Basically I’m trying to build a registration fee calculator, which would be easy enough, but there is a secondary fee that must be calculated that takes the model year minus the current calendar year to determine a depreciation percentage which in turn is multiplied against the MSRP of the vehicle and then multiplied by .5% to determine the extra fee, which will be added to the other fees at the end. :exploding_head:

There are other conditions that apply if a vehicle year determination is over 16, but that is easily handled through a simple calculation and conditional jump logic, which only requires to separate gambits making a Math.js call (though I could use the above technique to combine them if it is possible).

Anyone curious about Math.js can find it here. This is the same API that is used to calculate the number of correct answers in a quiz in your bot (much simpler process).

2 Likes

Hey @Levi,

I think it’s about time that you upgrade to the next level of self-actualization and start learning to code :smile:

These are custom logic which you can do with a simple program code.
I would highly recommend to use Glitch (https://glitch.com)

With this you can make an API of yourself, which can do anything you want, including these custom logical calculations based on given parameters. There is definitely a small curve to learn to do this, but Glitch makes it really simple with their new Zine which explains how Web App works.

Check this: https://glitch.com/you-got-this

1 Like

Cool! I will check it out for sure. I think you are right haha!

1 Like