extending ncalc

Topics: General, New Features
Feb 13, 2012 at 9:05 AM

are there any tips or guides to extend the function list of Ncalc

i also want to extend max,min function to accept a list of CSV

plus to add a few functions like average, Log2 , cuberoot etc.

any pointers which Codefile to look for to add/change the functions

need help with this regard . thanx

Mar 27, 2012 at 1:20 PM

arvindps, look at the "Visit(Function function)" method in EvaluateVisitor.cs.  There is a switch that handles the built in functions.  You could just expand this.

Mar 28, 2012 at 10:02 AM

Thanks

yes i found the Function parser model and i am working on to extend more functions. It is  Domain folder.

Infact i have already extended the Min function to parse a list of values rather than two  vales
#region Min
        case "min":
            CheckCase("Min", function.Identifier.Name);
            if (function.Expressions.Length < 2)
                throw new ArgumentException("Min() takes atleast 2 arguments, Separated by a comma");
            double min = 0;
            double f = 0;
            for (int i = 0; i < function.Expressions.Length; i++)
            {
                try
                {
                    f = Convert.ToDouble(Evaluate(function.Expressions[i]));
                    if (i == 0) min = f;
                    else
                        min = (min < f) ? min : f;
                }
                catch
                {
                    throw new ArgumentException("Min() function has Invalid parameters. All parameters must be numeric separated by Comma");
                }
            }
            Result = min;
            break;
        #endregion


The following Code extends the Secant function             

case "sec":
        CheckCase("sec", function.Identifier.Name);
        if (function.Expressions.Length != 1)
            throw new ArgumentException("Sec() Secant takes exactly 1 argument");
        Result = (1 / Math.Cos(input));
        break;

Please post any advice/ suggestions, if any improvements

thank you

arvind ps

Apr 30, 2012 at 3:05 PM

there is a fork of ncalc i made which enables you to use the Managed Extensibilty Framework [MEF] to add extra functions just by implementing an interface and tagging it with the right export - it means all your new functions can live in their own dll seperate from ncalc.

May 1, 2012 at 2:03 PM

Yes, it will be a good idea. Is it available under GPL or MIT or is it a for Buy product.

If it is a for Buy , then please post a trial download link, with documentation

I hope it is compatible with vs 2010, and that it can be ported to a Silverlight inbrowser application.

We are in the process of making quizz based on Maths , a prototype for WordQuiz just for demo is posted here

http://dl.dropbox.com/u/71964910/MyFantasyPicksTestPage.html

the Math quiz will have equations posted with random numbers and choices offered . The answer ofcourse is calculated on basis

of Ncalc

regards

arvind

 

May 24, 2012 at 2:13 PM

its a fork of codeplex, same license, you can download code here:

 

http://ncalc.codeplex.com/SourceControl/network/forks/GreyCloud/NCalcMEFed

hope it helps