# LGA-04: Haskell Lists (Part I)¶

Implement the following functions in Haskell. You don’t need to get every single one of them working, you need only show reasonable effort. Reasonable effort might be trying them all, but not being able to get 2 of them working. I would not consider only getting half of them working a reasonable effort, for example.

1. prodOfHeads takes two lists and returns the product of the heads:

GHCi> prodOfHeads [2,3] [4,6]
8

2. longerList takes two lists and returns the longer one:

GHCi> longerList [1,2] [4,5,6]
[4,5,6]


(your choice which to return if same length)

3. evenOdd takes a number $$n$$ and returns a list containing the first $$n$$ even numbers followed by the first $$n$$ odd numbers:

GHCi> evenOdd 4
[2,4,6,8,1,3,5,7]


You may assume $$0 \leqslant n < 1000$$.

4. addToTail takes two lists and returns a list with the head of the first list at the end of the second:

GHCi> addToTail [1,2,3] [4,5,6]
[4,5,6,1]

5. replaceLast takes two lists and returns a list with the last element of the second list replaced by the last element of the first list:

GHCi> replaceLast [1,2,3] [4,5,6]
[4,5,3]

6. removeHeads takes two lists and concatenates them, minus the first elements:

GHCi> removeHeads [1,2,3] [4,5,6]
[2,3,5,6]

7. replaceList takes two lists and replaces the first $$n$$ elements (where $$n$$ is the length of the first list) with the elements of the first list:

GHCi> replaceList [1,2] [4,5,6,7]
[1,2,6,7]
GHCi> replaceList [1,2,3,4] [7,8]
[1,2,3,4]