Create a Haskell file and complete it according to the assignment. Name it <firstname>_<lastname>_AT6.hs
.
Send me an email at: sristic[at]seas[dot]upenn[dot]edu by 2019-11-15 End of Day, containing:
<firstname>_<lastname>_AT6.hs
.Be sure to give your email the subject line “BOOTS: AT6”.
Complete all points to the best of your ability. If you get stuck and have tried everything you can think of to get unstuck, explain your thinking, demonstrate effort and time.
Copy-paste the code below into https://repl.it/languages/haskell (or, if you have installed Haskell on your computer, open your text editor of choice). The stub code is also found in this file.
Replace the parts marked undefined
so that they meet the specification in the comments.
You may not use library functions in your solutions.
Chapters 2 through 5 of Learn You a Haskell are a good reference for this material.
(the lines that start with two hyphens are comments which describe the line(s) below, the compiler ignores them)
-- map' applies (f :: a -> b) to each element of the list (l :: [a])
-- Here, I've provided you with the cases, for the examples below, you'll
-- have to break down the cases yourself
map' :: (a -> b) -> [a] -> [b]
map' f [] = undefined
map' f (h:t) = undefined
-- intersperse' intersperses (x :: a) in the list (l :: [a]).
-- For example, intersperse' 1 [2,3,4,5,6] gives [2,1,3,1,4,1,5,1,6]
-- and intersperse' 1 [] gives []
intersperse' :: a -> [a] -> [a]
intersperse' = undefined
-- concat' takes a list of lists and concatenates them together into a
-- single list
-- For example, concat' [[1,2],[],[4],[1,5,2]] gives [1,2,4,1,5,2]
concat' :: [[a]] -> [a]
concat' = undefined
-- invert' takes a list of pairs (a, b) and gives back the list with all
-- the pairs reversed
-- For example, invert' [('a', 1), ('b', 4)] gives [(1, 'a'), (4, 'b')]
-- and invert' [] gives []
invert' :: [(a, b)] -> [(b, a)]
invert' = undefined
-- Leave this line in, it keeps the repl from throwing an error when you
-- run the code.
-- Chapter 9 of Learn You a Haskell gets into what this line actually means
-- (it's deep).
main = return ()