Пример #1
0
        public static Entity Simplify(List <Entity> args)
        {
            MathFunctions.AssertArgs(args.Count, 2);
            var r1 = args[0].InnerSimplify();
            var r2 = args[1].InnerSimplify();

            args = new List <Entity> {
                r1, r2
            };
            if (MathFunctions.IsOneNumber(args, 1))
            {
                return(MathFunctions.GetAnotherEntity(args, 1));
            }
            else if (MathFunctions.IsOneNumber(args, 0))
            {
                return(0);
            }
            else if (r1.entType == Entity.EntType.NUMBER && r2.entType == Entity.EntType.NUMBER)
            {
                var(n1, n2) = ((r1 as NumberEntity).Value, (r2 as NumberEntity).Value);
                return(InnerSimplifyAdditionalFunctional.KeepIfBad(n1 * n2, r1 * r2, n1, n2));
            }
            else
            {
                return(r1 * r2);
            }
        }
Пример #2
0
        public static Entity Eval(List <Entity> args)
        {
            MathFunctions.AssertArgs(args.Count, 2);
            var r1 = args[0].InnerEval();
            var r2 = args[1].InnerEval();

            args = new List <Entity> {
                r1, r2
            };
            if (r1.entType == Entity.EntType.NUMBER && r2.entType == Entity.EntType.NUMBER)
            {
                return(new NumberEntity((r1 as NumberEntity).Value * (r2 as NumberEntity).Value));
            }
            else if (MathFunctions.IsOneNumber(args, 1))
            {
                return(MathFunctions.GetAnotherEntity(args, 1));
            }
            else if (MathFunctions.IsOneNumber(args, 0))
            {
                return(0);
            }
            else
            {
                return(r1 * r2);
            }
        }