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 evall: exp1 -> value thatevaluat

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

1 Expert Approved Answer
Step: 1 Unlock

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

blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Accounting Questions!