parnoldx / nasc

Do maths like a normal person

Home Page:http://parnoldx.github.io/nasc/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Feature Request - Custom functions

asd-noor opened this issue · comments

I don't if this feature is available or not. If available, can anyone point me to the Wiki/Help. I can't find any.
If it's not available, can you implement it please? It's helpful if I can define temporary functions for doing some math.

For example:
to calculate kinetic energy it would be helpful to have a function like

kineticEnergy(mass, speed) = 0.5 * mass * speed^2

and assign it like car = kineticEnergy(1000 kg, 3 m/s)

or assign it like car = kineticEnergy(1000, 3) <- if it's like this, we have to calculate the units ourselves, but that's acceptable.

commented

Hi, this should be possible but I have no time to test it right now.
I think it should be like this:
Define: function func1 5*\x
Call: func1(3)

But I have to fix something to make it work when I find time.

commented

This works now. So for your example
function kineticEnergy 0.5 * \x* \y ^2
You the can assign it like you wanted. Units also works

The variables must be \x, \y, \z, \a,...