Math Parser for Objective C, iOS and OSX
This is the documentation for the MathParser class that is implemented in Objective C to target iOS and OSX platforms.
MathParser provides capability to parse and evaluate formulas given as strings at runtime.
MathParser expressions can contain variables and functions. A typical use case in a few lines of Objective C code is as follows:
MathParser *parser = [[MathParser alloc] init]; parser.expression = @"x+y/5-sin(x-1)"; // will be converted to uppercase before parsing. [parser setVariable:@"X" withNewValue: 5]; [parser setVariable:@"Y" withNewValue: 10]; double result = parser.value; // expression will be parsed and evaluated.
MathParser::expression property documentation contains the list of predefined functions you can use.
MathParser supports user defined functions. You can implement your own functions and plug them into a parser instance by implementing the Function protocol.
User defined variable values can be assigned via setVariable:withNewValue: (MathParser) method.
If the problem domain is too big to set all possible variables ahead of time, you may set the MathParser::variableDelegate property to an implementation of VariableDelegate protocol.
MathParser uses Foundation framework.
You may find more information at http://www.mathparsers.com