Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

**in Haskell language** Expression Tree Functions Develop an evaluating function that computes the result when one of your arithmetic expression trees (passed as the first

**in Haskell language** "Expression Tree Functions"

Develop an evaluating function that computes the result when one of your arithmetic expression trees (passed as the first argument) is evaluated using a specific value of x (passed as the second argument). As a clarifying example, the evaluation of the structure

(Addition (Value x) (Value 3))

using a value of 2 should result in a value of 5.

Develop an string representation function that converts one of your arithmetic expression trees (passed as the only argument) into a list of characters that is the way the expression would typically be "written". As a clarifying example, the string representation of the structure

(Addition (Value x) (Value 3))

should be (x + 3) .

Develop a drawing function that creates a graphical [[Char]] representation of a tree argument. Your objective here should be to generate a return value that, when passed as the argument x to putStr (unlines x), appears to be "tree-like". As a clarifying example, the "tree-like" depiction of:

(Multiplication (Value 4) (Addition (Value x) (Value 3)))

could* appear, when printed using putStr unlines, as:

( * ) ----- 4

|

--- ( + ) ---- x

|

--- 3

*Other visualizations are permitted - it doesn't need to appear exactly the same as the result depicted above, but your result must be a graphically-represented tree, drawn with every connection necessary to depict is as a connected graph. (To clarify, you should not expect full marks on this component if you do not have all the vertical and horizontal lines seen above)

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

Students also viewed these Databases questions

Question

In the QRadar interface, where are user accounts added?

Answered: 1 week ago