July 2023
Intermediate to advanced
670 pages
17h 13m
English
Consider a binary tree with a type:
| | data BinaryTree a = Leaf | Branch (BinaryTree a) a (BinaryTree a) |
Write the definition of the binary tree type, and then add the following functions:
| | -- Turn a binary tree of strings into a pretty-printed string |
| | showStringTree :: BinaryTree String -> String |
| | |
| | -- Add a new integer into a binary tree of integers |
| | addElementToIntTree :: BinaryTree Int -> Int -> BinaryTree Int |
| | |
| | -- Check to see if an int value exists in a binary tree of ints |
| | doesIntExist :: BinaryTree Int -> Int -> Bool |
Write a new version of your eval function named safeEval that will return an error if the user tries to divide by zero. It should have ...