Question: 1 Haskell Complete the following problems in Haskell. 1. Write a function of type [a] ->[a]->[a] that first reverses each of the two lists, and

![function of type [a] ->[a]->[a] that first reverses each of the two](https://dsd5zvtm8ll6.cloudfront.net/si.experts.images/questions/2024/09/66f303aa9ee77_21866f303aa3a28d.jpg)
1 Haskell Complete the following problems in Haskell. 1. Write a function of type [a] ->[a]->[a] that first reverses each of the two lists, and then appends all the resulting lists together. So f1 [1,2] [3,4,5] should return [2,1,5,4,3] 2. Write a function of type [a] ->[b] -> [c] -> [(a , (b , c))] list that takes in three input lists and returns a new one whose elements are nested pairs of pairs of the corresponding elements from the first, second, and third lists. You may assume the lists have the same length So f2 [ 1, 2] ["a", "b"] [True,False] should return [(1, ("a" ,True)) , (2, ("b" ,False))] 3. Write a function of type [(a,b)] -> [a] that returns a list of the first components of the pairs in the input list. So f3 [(1,2), (3,4)] should return [1,3] 4. Write a function of type [a] -> [a] -> [a] which interleaves ele- [2,4,6] ments from the two input lists, starting with the first list. Sof4 [1,3,5] should return [1,2,3,4,5,6]. 5. Write a function of type (a -> b) -> (b -> c) -> [a] -[c] list that applies its two functional inputs to the elements of the input list So calling f5 g f [a1, , an] should produce the same result as [f (g al),... , f (g an)] 6. Write a function of type (a -> b -Bool) -> [a] -> [b] -> [(a , b)] which returns a list of pairs of the corresponding elements of the input lists (which 1 Haskell Complete the following problems in Haskell. 1. Write a function of type [a] ->[a]->[a] that first reverses each of the two lists, and then appends all the resulting lists together. So f1 [1,2] [3,4,5] should return [2,1,5,4,3] 2. Write a function of type [a] ->[b] -> [c] -> [(a , (b , c))] list that takes in three input lists and returns a new one whose elements are nested pairs of pairs of the corresponding elements from the first, second, and third lists. You may assume the lists have the same length So f2 [ 1, 2] ["a", "b"] [True,False] should return [(1, ("a" ,True)) , (2, ("b" ,False))] 3. Write a function of type [(a,b)] -> [a] that returns a list of the first components of the pairs in the input list. So f3 [(1,2), (3,4)] should return [1,3] 4. Write a function of type [a] -> [a] -> [a] which interleaves ele- [2,4,6] ments from the two input lists, starting with the first list. Sof4 [1,3,5] should return [1,2,3,4,5,6]. 5. Write a function of type (a -> b) -> (b -> c) -> [a] -[c] list that applies its two functional inputs to the elements of the input list So calling f5 g f [a1, , an] should produce the same result as [f (g al),... , f (g an)] 6. Write a function of type (a -> b -Bool) -> [a] -> [b] -> [(a , b)] which returns a list of pairs of the corresponding elements of the input lists (which
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
