Ejemplo n.º 1
0
        public Expr ToExpr()
        {
            var(VN, VSN, VRN) = _variables.OfType <VarPowN, VarN, VarRootN>();
            var numerators = VN.Concat <Variable>(VSN).Concat(VRN).Select(f => f.ToExpr());

            var(VD, VSD, VRD) = _variables.OfType <VarPowD, VarD, VarRootD>();
            var denominators = VD.Concat <Variable>(VSD).Concat(VRD).Select(f => f.ToExpr());
            var numerator    = numerators.IsEmpty() ? new One() : numerators.Aggregate((n1, n2) => MultiplyOp.Create(n1, n2));

            if (denominators.IsEmpty())
            {
                return(numerator);
            }
            return(DivideOp.Create(numerator, denominators.Aggregate((n1, n2) => MultiplyOp.Create(n1, n2))));
        }