Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Haskell Programming (Not any other Language): Simply answer the question (Code) For Problems 4-7, we'll use this definition of binary trees that include values at

Haskell Programming (Not any other Language): Simply answer the question (Code)image text in transcribed

For Problems 4-7, we'll use this definition of binary trees that include values at the leafs and interior nodes. Tree is polymorphic, so you can have a Tree Int or Tree Float or Tree (Int, Int), etc. data Tree aLeaf a Branch a (Tree a) (Tree a) deriving (Eq, Show) 4.[5 points] Wrie a treeEq function that is our own version of tree equality. It should behave just like ::: If x and y are trees, then ( treeEg x-treeEq y ) == ( x- y). For the function type, you need two trees of an equality-testable type. (You can't test treeEq (Leaf sqrt) (Leaf sqrt), for example.) 5. 5 points] Write a treeShow function that is our own version of show. It should take a tree and return a string (a list of characters). It should behave just like show: If x is a tree, then tre eshow x == show X. For the function type, you need a tree of showable values. (You can't treeShow (Leaf sqrt), for example.) For Problems 4-7, we'll use this definition of binary trees that include values at the leafs and interior nodes. Tree is polymorphic, so you can have a Tree Int or Tree Float or Tree (Int, Int), etc. data Tree aLeaf a Branch a (Tree a) (Tree a) deriving (Eq, Show) 4.[5 points] Wrie a treeEq function that is our own version of tree equality. It should behave just like ::: If x and y are trees, then ( treeEg x-treeEq y ) == ( x- y). For the function type, you need two trees of an equality-testable type. (You can't test treeEq (Leaf sqrt) (Leaf sqrt), for example.) 5. 5 points] Write a treeShow function that is our own version of show. It should take a tree and return a string (a list of characters). It should behave just like show: If x is a tree, then tre eshow x == show X. For the function type, you need a tree of showable values. (You can't treeShow (Leaf sqrt), for example.)

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

Machine Learning And Knowledge Discovery In Databases European Conference Ecml Pkdd 2015 Porto Portugal September 7 11 2015 Proceedings Part 3 Lnai 9286

Authors: Albert Bifet ,Michael May ,Bianca Zadrozny ,Ricard Gavalda ,Dino Pedreschi ,Francesco Bonchi ,Jaime Cardoso ,Myra Spiliopoulou

1st Edition

3319234609, 978-3319234601

More Books

Students also viewed these Databases questions

Question

Detailed solution please

Answered: 1 week ago