-
Notifications
You must be signed in to change notification settings - Fork 154
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How to add a √ (nthroot) operator? #36
Comments
This is slightly complicated. The way things are right now, when the parser encounters a binary operator, it takes the left expression as the first argument and the right expression as the second argument. Thus, I'll think about this. I agree it's a good suggestion, but it'll require some work to do. |
The other thing to consider is that |
"3 times the square root of 64" is a result of Implicit Multiplication. Is possible to let binary operator to have higher precedence over implicit multiplication? And |
This is for Sqrt - Nthroot can be added in similar way Step 1In file _DDOperatorInfo.m under function
..................... Add Code Here -->precedence++; Step 2
extern NSString *const DDOperatorSqrt;
NSString *const DDOperatorSqrt = @"Sqrt"; Step 3 (Finally)Add the following code to your project (preferably in viewDidLoad method of your first view controller) before using the √ operator DDMathFunction sqrtFunction = ^ DDExpression* (NSArray _args, NSDictionary *variables, DDMathEvaluator *evaluator, NSError *_error)
|
For NthRoot Step 1In file _DDOperatorInfo.m under function precedence++;
Step 2 (Follow like the above)Step 3DDMathFunction function = ^ DDExpression* (NSArray _args, NSDictionary *variables, DDMathEvaluator *evaluator, NSError *_error)
|
I just added API to define your own operators, so for now (at least) it's possible to add this yourself (check out the Wiki for details). I'm looking at what it would take to build this in, so I will leave this issue open. |
for square root, I just simple replace √( with sqrt( and it is a walk around to the problem... |
What's the proper way to add the √ (nthroot) operator? such that:
3√8
will work as:
nthroot(8,3)
Is there an existing operator which I can use as a reference implementation?
The text was updated successfully, but these errors were encountered: