Answered step by step
Verified Expert Solution
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)
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
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started