Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

-Could you please solve the following question in Haskell. Extend the abstract syntax tree data type Expr to add new operations Neg (negation), Min (minimum),

-Could you please solve the following question in Haskell.

Extend the abstract syntax tree data type Expr to add new operations Neg (negation), Min (minimum), Max (maximum), and Exp (exponentiation).

 

data Expr = ...

| Neg Expr

| Min Expr Expr

| Max Expr Expr

| Exp Expr Expr

...

deriving Show

Then extend the eval function (in the EvalExpr module) to add these new operations with the following informal semantics:

Neg e negates the value of e Neg (Val 1) is (Val (-1))

Min l r returns the smaller value of l and r

Max l r returns the larger value of l and r

Exp l r raises l to the poewr r

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Design And Implementation

Authors: Edward Sciore

2nd Edition

3030338355, 978-3030338350

More Books

Students also viewed these Databases questions

Question

=+Identify the type of global assignment for which CCT is needed.

Answered: 1 week ago