Giter Site home page Giter Site logo

Comments (7)

harperjiang avatar harperjiang commented on June 21, 2024

Hello,

All the functions are defined in class "FuncExpression".

To create a new function, first you need to extend "FuncCallback" to declare the parameters type and how you calculate the return value. Line 46-64 of FuncExpression.m is an example.

Then you need to register your function with a name you want to use. Check line 152-161, where I have registered 3 functions.

After these steps you can try to invoke your new function from the command line.

I am glad you are interested in this small tool. Feel free to write me email if you have further questions.

Regards,
Harper

from ioscalculator.

mutelove avatar mutelove commented on June 21, 2024

Thank you for you response,
I mean add function in calculator for calculate derivation, for example d(tan(x))/dx

from ioscalculator.

harperjiang avatar harperjiang commented on June 21, 2024

I see.

These pre-defined functions are what I called "Basic Functions", and they are managed in class "BasicFuncExpression".

In this file I have currently defined three basic function SIN/COS/LN, and you can add more functions as you like with the following steps:

  1. Add a new type to the enum BasicFuncType
  2. Modify BasicFuncExpression.m to give the result of differentiation/integration for this new function
  3. Modify the "calculus.lpp" and "calculus.ypp" to add new function name to the parser so that the new function can be recognized.

Hope this helps.

Regards,
Harper

from ioscalculator.

mutelove avatar mutelove commented on June 21, 2024

I did it, but new function do not work

from ioscalculator.

mutelove avatar mutelove commented on June 21, 2024

I think there is need some changes in "CalculusLexer.cpp" and "CalculusParser.cpp" and "CalculusParser.h" I tried to do, but I had no results.

from ioscalculator.

harperjiang avatar harperjiang commented on June 21, 2024

These files should be generated by flex/bison automatically. I never manually modify them.

There may be some problem with the configuration of XCODE that prevent it from recompile the lpp file. You can manually invoke flex and bison from the command line to regenerate the files, then refresh the workspace. I will check whether I can find the command I use before and send it to you.

from ioscalculator.

mutelove avatar mutelove commented on June 21, 2024

thank you , my email is : rashvand at hotmail.com

from ioscalculator.

Related Issues (1)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.