예제 #1
0
        protected override Expression VisitSum(Sum A)
        {
            List <Expression> terms = new List <Expression>();

            foreach (Expression i in A.Terms)
            {
                terms.Add(Visit(i));
            }
            return(EvaluateVisitor.EvaluateSum(terms));
        }
예제 #2
0
 // Evaluate x*A, distributing x if A is Add.
 public static Expression Distribute(Expression x, Expression A)
 {
     if (A is Sum || x is Sum)
     {
         return(EvaluateVisitor.EvaluateSum(Sum.TermsOf(A).SelectMany(i => Sum.TermsOf(Distribute(i, x)))));
     }
     else
     {
         return(Product.New(A, x).Evaluate());
     }
 }
예제 #3
0
        public static IEnumerable <Expression> Evaluate(this IEnumerable <Expression> f, IDictionary <Expression, Expression> x0)
        {
            EvaluateVisitor V = new EvaluateVisitor();

            return(f.Select(i => V.Visit(i.Substitute(x0))));
        }
예제 #4
0
 public static IEnumerable<Expression> Evaluate(this IEnumerable<Expression> f, IDictionary<Expression, Expression> x0)
 {
     EvaluateVisitor V = new EvaluateVisitor();
     return f.Select(i => V.Visit(i.Substitute(x0)));
 }