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

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!