Units
Hello,
i was just wondering if it is already in some way possible to calculate expressions with units using NCALC, or if it could theoretically be implemented in the future:
For example: 10mm + 10mm = 20mm 10mm + 10N : Failed evaluation 10mm * 10N = 100 Nmm 10N / 10mm = 1 N mm^-1 10mm * 10mm = 100 mm^2 10mm + 1m = 1010mm
Greetings, Simon
Good morning Simon!
Next week I'm going to start to work on #137. I will evaluate if this is possible with Parlot or we would need some event handling (probably the way at this version).
Great. If your evalution turns out optimistic and you are open to it, don't hesitate to get in touch to see if I there is something I could do to help.
@shockfield I'm thinking in your problem, I think this is not possible at Parlot, is more an evaluation problem and not a parsing problem.
I think you can create your custom logic using OnEvaluateParameter and [] around the numbers and check the unit at the end of the variable name. Feel free to send questions or more ideas.
@gumbarros , hi can you show me an example of what you mean? something like this?
e.EvaluateParameter += delegate(string name, ParameterArgs args) { if (name.EndsWith("mm")) Unit = "mm" ..? };
From your documentation:
e.Parameters["Pi2"] = new Expression("Pi * [Pi]");
What is the difference between Pi and [Pi] here? What purpose do the [] serve?
e.EvaluateParameter += delegate(string name, ParameterArgs args) { if (name.EndsWith("mm")) Unit = "mm" ..? };
Yes this is my idea.
What is the difference between Pi and [Pi] here? What purpose do the [] serve?
Nothing. [] is to prevent conflicts with other things in the parser, like [not] is a variable and not is a unary operator. [Pi] and Pi have no difference.
@shockfield, fill free to close the issue if it is resolved
Closed due inactivity.