public Add(Node l, Node r) : base(l, r, "Add") { }
public BinOp(Node l, Node r, string operation) { this.left = l; this.right = r; this.op = operation; }
public Mult(Node l, Node r) : base(l, r, "Mult") { }
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))); } }