Esempio n. 1
0
 public static Expression InverseExpression(Expression exp)
 {
     Expression ret = new VariableExpression();
     Expression s = exp;
     do
     {
         ret = s.GenerateInverse(ret);
         foreach (var i in s.Children)
             if (i.HasVariable)
             {
                 s = i;
                 break;
             }
     }
     while (!(s is VariableExpression));
     return ret;
 }
Esempio n. 2
0
 internal Expression Generate(Expression parent, int level, Random rand)
 {
     Expression ret = null;
     if (level == 0)
     {
         if (!g)
         {
             ret = new VariableExpression();
             g = true;
         }
         else
         {
             ret = new ConstantExpression();
             ret.Generate(this, level, rand);
         }
     }
     else
     {
         ret = (Expression)Activator.CreateInstance(ExpressionTypes[rand.Next(0, ExpressionTypes.Length)]);
         ret.Generate(this, level - 1, rand);
     }
     ret.Parent = parent;
     return ret;
 }