Question: datatype binaryOperator = BOP_PLUS | BOP_MINUS | BOP_TIMES; datatype unaryOperator = UOP_MINUS | UOP_NOT; datatype expression = EXP_NUM of int | EXP_ID of string |
datatype binaryOperator = BOP_PLUS | BOP_MINUS | BOP_TIMES; datatype unaryOperator = UOP_MINUS | UOP_NOT; datatype expression = EXP_NUM of int | EXP_ID of string | EXP_BINARY of {opr: binaryOperator, lft: expression, rht: expression} | EXP_UNARY of {opr: unaryOperator, opnd: expression} ; Write a function in ML that takes a single value of type expression and that returns a transformed expression such that each binary multiplication with an operand of 0 is simplified to 0 (i.e., e1 * 0 is 0). The result of this transformation should not include any multiplications with a 0 operand.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
