| | |
Summary: CS 4700 Haskell Programming Assignment 5
40 Points
1. (4 points) Write a Haskell function
isPalindrome :: [Char] -> Bool
to recognize palindromes like "Madam, I\'m Adam"
Notice you need to make all capital letters lower case and throw out punctuation
before comparing.
2. (4 points) Define a function to replace one substring with another
subst:: [Char] ->[Char]->[Char]->[Char]
The result of
subst "Fish & Chips and Vinegar" "Chip" "Boat" yields "Fish &Boats and Vinegar"
If there is no occurrence of the replacement string, the original string should
remain unchanged.
What happens if you enter
subst "Fish & Chips and Vinegar" "" "Boat"
3. Define a Haskell type for a binary search tree, given the following Haskell type
for Integer binary trees
data Tree = Nil | Node Int Tree Tree
deriving (Show)
Define the following functions on binary search trees.
|