datatype node = Constant of int | Symbol of string | Negate of node | Add of node*node | Subtract of node*node; fun tostring (Constant c) = Int.fmt StringCvt.DEC c | tostring (Symbol s) = s | tostring (Negate n) = "-" ^ tostring(n) | tostring (Add (x, y)) = "(" ^ tostring(x) ^ "+" ^ tostring(y) ^ ")" | tostring (Subtract (x, y)) = "(" ^ tostring(x) ^ "-" ^ tostring(y) ^ ")";