I am attempting to define and format a custom function in Swift via the mechanisms built into DDMathParser. I have tried following the instructions on the Wiki, but for someone who is relatively new to Swift coding there are not enough specifics. The function I want to create would be called "dsi" and would call the already built-in functions sin() and dtor() like so: sin(dtor()).
Any advice?
Thanks!
An example of declaring a custom function can be found in the unit tests for DDMathParser, which I'll include here:
You would obviously want to provide a different implementation of the evaluation block passed to the
Functionconstructor.Incidentally, are you aware that DDMathParser has support for the exact case you're describing already? The
Evaluatorobject has anangleMeasurementModeproperty. The default value is.Radians, but you can change it to.Degreesif you create your own evaluator.