Project name:
Project Description:

Max length 200 characters

Tags:
Username:
Email address:
Password:
Repeat password:

WolfCube software and hardware

Projects

WolfCalc is a C++ library with a simple goal in mind: it parses strings and evaluate its contents. For example a string such as "1+2" will output 3.

Of course, many more functions are implemented, for example, functions and constants are possible. Have a look at this code:

long double result = wolfcalc::evaluate("1+sin(p)")
printf("%Lf", result);

This will print 1.

Also, with this library you can add very easily your own functions and operators, just like this:

op *addition = //class op (operator)
{
    "+",  //the string of the operator
    1,    //its priority to other operators (0 is max)
    OPERATOR { return p1 + p2; } //OPERATOR is a macro that defines the heading of a lambda function
                                 //p1 and p2 are the two addends
                                 //more information in the documentation
};

wolfcalc::op::add( addition );

The same thing goes for functions:

function *sine = //class function
{
    "sin",  //the string of the function
    FUNCTION { return sinl(v[0]); } //FUNCTION is another macro just like OPERATOR
                                    //v is the vector of the function arguments
                                    //more information in the documentation
};

wolfcalc::function::add( sine );

You can download the library here


Site hosted by heliohost.org

This website has been accessed 5974 times