parnoldx / nasc

Do maths like a normal person
http://parnoldx.github.io/nasc/
GNU General Public License v3.0
560 stars 37 forks source link

Feature Request - Custom functions #158

Closed asd-noor closed 4 years ago

asd-noor commented 4 years ago

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.

parnoldx commented 4 years ago

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.

parnoldx commented 4 years ago

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,...