Ejemplo n.º 1
0
        private IExpressionType doPredefinedFunc(Function f)
        {
            Computator     comp = new Computator();
            Simplification s    = new Simplification();

            switch (f.getName())
            {
            case "plot":
                MathList mathList = (MathList)f.getOperands()[0];
                Variable var      = (Variable)f.getOperands()[1];
                Interval interval = (Interval)f.getOperands()[2];

                PlotModel plot = new PlotModel(mathList, var, interval);
                plot.drawGraphics();
                return(f);

            case "integrate":
                Integrate       i       = new Integrate((Variable)f.getOperands()[1]);
                IExpressionType operand = f.getOperands()[0].doOperation(comp);
                if (operand.getType() == Types.VarDefinition)
                {
                    return(i.integrate((IMathExpression)operand.getOperands()[1]));
                }
                IExpressionType integrated = i.integrate((IMathExpression)operand);
                return(integrated.doOperation(comp));
            }

            List <IExpressionType> list = new List <IExpressionType>();

            foreach (var op in f.getOperands())
            {
                list.Add(op.doOperation(comp));
            }

            return(s.simplify(new Function(f.getType(), list, f.getName())));
        }