Question: Please Implement Using SML for Below Problems: 5. Using pattern matching, define a function eval1: exp1 -> value that evaluates expression of the type

Please Implement Using SML for Below Problems: 5. Using pattern matching, define a function eval1: exp1 -> value that evaluates expression of the type exp1 to result of the type value. Note that this function also needs to check for possible errors (hint: using case expressions). For example, 1 + (2 < 3) evaluates to an error because we cannot add int and bool values. 6. Define an algebraic datatype exp2 to represent int constant, plus expres- sion, less than expression, or if-then-else expression. 7. Using pattern matching, define a function eval2: exp2 -> value that evaluates expression of the type exp2 to result of the type value. You should check for errors for if-then-else expression as well.
Step by Step Solution
There are 3 Steps involved in it
Function basics Function syntax and types A function in ML is written as follows fn arg returnValue For example the following function returns an integer that is one greater than its argument fn x x 1 ... View full answer
Get step-by-step solutions from verified subject matter experts
