Question
Your submitted file must be interpretable by GHCi interpreter in Haskell (a) Define function flat :: [[a]] -> [a] that receives a list of lists
Your submitted file must be interpretable by GHCi interpreter in Haskell
(a) Define function flat :: [[a]] -> [a] that receives a list of lists and flattens it into a list. For example, if the input is [[1,2],[3,4]] then the output must be [1,2,3,4]. If the input is ["hello ", "world"] then the output is "hello world". Pattern match on the input list.
(b) Define function findInd :: (Eq a) => a -> [a] -> Int that receives an item and a list and returns the index in the list where the input item resides. If the item is not in the list, it must raise an exception. For example, findInd 7 [5..20] must return 2, whereas findInd 3 [5..20] must raise an exception. Hint: You may need to define a helper function that keeps track of indexes as it traverses the input list.
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