Here is a definition for Haskell's patterns. 1) A variable is a pattern that matches anything and binds to it. 2) An underscore is a pattern that matches anything. 3) A constant is a pattern that matches only itself. 4) A tuple of patterns is a pattern that matches any tuple of the same size whose contents match the subpatterns. 5) A list of patterns is a pattern that matches any list of the same size whose contents match the subpatterns. 6) A cons of two patterns is a pattern that matches any non-empty list whose head and tail match the two subpatterns. 1.) Use equations, pattern matching, and guards to define the following functions on tuples and lists. a) A function f1 that consumes a 4-tuple and swaps the middle two elements. f1 (1,2,3,4) ==> (1,3,2,4) b) A function f2 that consumes a list of length at least two and swaps the first two elements of the list. f2 [1,2,3,4,5] ==> [2,1,3,4,5] c) A function f3 that squares positive numbers and cubes negative numbers. d) A function f4 that consumes a list of pairs of numbers and uses function f3, from part (c), to square every positive number from each pair and cube every negative number from each pair. f4 [(-2,2), (3,0), (-1,-3)] ==> [(-8,4), (9,0), (-1,-27)] Hint: Define f4 using a list comprehension. Use a pattern with the generator. e) Write a function f5 that consumes one character and converts a lower case character to upper case and an upper case character to lower case and returns any other character unchanged. Use your f5 to define a function f6 that consumes a string and reverses the case of every letter in the string. f6 "Hello There 123x" ==> "hELLO tHERE 123X" 2.) For each function below, rewrite the function is a clearer way. Hint: For each function, look at its type and then choose a better pattern for the equation. a) g1 x = 1 + fst x b) g2 x = 1 + head x c) g3 x = (snd x, fst x) d) g4 x = (head x, tail x) e) g5 x = (head (tail x)) : (head x) : (tail (tail x)) f) g6 x = (head x) + (head (tail x)) : (tail (tail x))