Example #1
0
 public Add(Node l, Node r)
     : base(l, r, "Add")
 {
 }
Example #2
0
 public BinOp(Node l, Node r, string operation)
 {
     this.left = l;
     this.right = r;
     this.op = operation;
 }
Example #3
0
 public Mult(Node l, Node r)
     : base(l, r, "Mult")
 {
 }
Example #4
0
 public static Node Diff(Node n)
 {
     if (n is Number)
     {
         return new Number(0);
     } else if (n is Variable)
     {
         return new Number(1);
     } else if (n is Add)
     {
         Add m = (Add) n;
         return new Add(Diff(m.left), Diff(m.right));
     } else
     {
         Mult m = (Mult) n;
         return new Add(new Mult(Diff(m.left), m.right), new Mult(m.left, Diff(m.right)));
     }
 }