Write the following functions in Haskell. Be sure to make good use of pattern matching and recursion. All functions should include an appropriate type declaration.

Note

Each group member need to only implement one, so as long as all problems are covered between your group. Groups of 4: you will have one implemented twice.

1. gcd', which takes two integers, and computes their greatest common devisor recursively using Euclid’s algorithm:

$\begin{split}\gcd(a, b) = \begin{cases} a & \text{if } b = 0 \\ \gcd\left(b, a \bmod b\right) & \text{otherwise} \\ \end{cases}\end{split}$

Haskell has this function built in as gcd, so you can test it behaves equivalently.

2. filter', which takes a boolean-returning function $$f(x)$$ and a list, and returns the list only with the elements $$x$$ for which $$f(x)$$ is true. Haskell has this function built in as filter, so you can test it behaves equivalently. Your implementation should not use a list comprehension, nor Haskell’s built in filter function.

3. splitWords, which takes a list of integers and a string without spaces, and returns the string split with the word lengths specified in the list. For example:

GHCi> splitWords [3,8,8] "allsquashedtogether"
["all","squashed","together"]
GHCi> splitWords [3,3,5,4] "onetwothreefour"
["one","two","three","four"]
GHCi> splitWords [4] "blahblahblah"
["blah"]